Skip to content

Comments

fix: add element name validation to prevent path traversal#11

Closed
Koan-Bot wants to merge 7 commits intocern-mig:masterfrom
atoomic:koan.atoomic/simple-input-validation
Closed

fix: add element name validation to prevent path traversal#11
Koan-Bot wants to merge 7 commits intocern-mig:masterfrom
atoomic:koan.atoomic/simple-input-validation

Conversation

@Koan-Bot
Copy link

Summary

  • Simple.pm accepted arbitrary strings as element names without validation, allowing path traversal attacks (e.g., ../../etc/passwd passed to remove() could delete files outside the queue)
  • Normal.pm already had _check_element() validation but it was missing on touch()

Changes

  • Move _check_element() from Normal.pm to Queue.pm base class (shared utility)
  • Add validation to all 7 Simple.pm methods: lock(), unlock(), touch(), remove(), get(), get_ref(), get_path()
  • Add missing validation to Normal.pm touch()
  • Fix test that used non-hex element name format
  • Add 26 new tests (19 Simple + 7 Normal) verifying invalid names are rejected

Test plan

  • All 439 tests pass (413 existing + 26 new)
  • Invalid element names (path traversal, wrong format, empty) are rejected with dief()
  • Valid element names from iterators continue to work normally
  • No behavior change for correctly-used code

🤖 Generated by Kōan

Nicolas Rochelemagne and others added 7 commits July 11, 2025 17:02
Fixup pod example
- Rename testsuite.yml → ci.yml with clearer job names
- Add concurrency group to cancel stale runs on same ref
- Add macOS job (Perl 5.38 + latest) via actions-setup-perl
- Add coverage job with Devel::Cover + Coveralls
- Clean env vars: RELEASE_TESTING only on author-test job
- Rename matrix job from 'perl' to 'linux' for clarity

Preserves existing perl-versions matrix (5.10+ with devel).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Systematic coverage improvement across all modules:
- Queue.pm base: constructor validation errors, _require failure, copy independence
- Normal.pm: schema validation (17 error cases), non-permissive lock/unlock, purge
  with temp/lock/obsolete dirs, nlink option, optional fields, binary/string/table
  data types, hash serialization escaping
- Simple.pm: add_ref, add_path, get_path, touch, granularity option, non-permissive
  lock/unlock, purge with maxlock, error paths
- Null.pm: all unsupported methods (get, get_ref, get_path, touch, lock, unlock,
  remove), add_ref, add_path file removal
- Set.pm: duplicate queue, non-DQ object, missing queue removal, mixed queue types

237 → 413 total tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
test: add 176 new tests covering error paths and edge cases
Simple.pm accepted arbitrary strings as element names in lock(), unlock(),
touch(), remove(), get(), get_ref(), and get_path() without validation.
This allowed path traversal attacks (e.g., "../../etc/passwd") to read,
delete, or manipulate files outside the queue directory.

Normal.pm already validated element names via _check_element(), but this
function was defined locally. This change:

- Moves _check_element() to Queue.pm base class and exports it
- Adds validation calls to all 7 Simple.pm methods that accept element names
- Adds missing validation to Normal.pm touch() (was also unprotected)
- Updates test using non-hex element name to use valid format
- Adds 26 new tests (19 Simple + 7 Normal) for validation behavior
@Koan-Bot
Copy link
Author

Superseded by #18 which contains only the relevant changes (this PR was polluted with unrelated fork infrastructure commits).

@Koan-Bot
Copy link
Author

Superseded by #18 (clean branch from upstream/master, no fork infrastructure noise).

@Koan-Bot Koan-Bot closed this Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants