Skip to content

fix(snapshot): refuse receipt paths that escape the handed directory - #515

Merged
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
VARUN3WARE:fix/snapshot-verify-path-escape
Sep 13, 2026
Merged

kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
VARUN3WARE:fix/snapshot-verify-path-escape

Conversation

@VARUN3WARE

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • Relative ../, absolute path, and tables/../../… (subdir present) → exit 2
  • Honest relative export still verifies clean
  • tests/test_snapshot_verify.py + tests/test_dataset_snapshot.py
  • CI green

Reuse storage._validated_relative_key so verify_dataset_snapshot raises
(exit 2) before reading absolute or .. paths, matching the documented
join-only-onto-the-handed-root promise (Hebbian-Robotics#469).

@kstonekuan kstonekuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging.

Reusing _validated_relative_key is the right call: the verifier and storage roots now give one answer to "is this key inside the root".

Checked it against the three shapes from the issue plus the ones that must still pass:

../outside/secret.bin           REFUSE
/etc/hostname                   REFUSE
tables/../../outside/secret.bin REFUSE
C:\Windows\x                    REFUSE
samples.parquet                 accept, unchanged
assets/wrist_cam/frame_01.jpg   accept, unchanged

It normalizes ./a and a//b, which our exporter never writes and which does not reach the digest (_inventory_content_id hashes record.path).

@kstonekuan
kstonekuan merged commit ee43efe into Hebbian-Robotics:main Sep 13, 2026
8 checks passed
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.

[Bug]: Snapshot verify can read outside the handed directory via receipt paths

2 participants