[FIX]: contain deserialized payload artifacts#106
Conversation
|
Thanks — updated in I kept the explicit absolute/ Validation: uv run pytest tests/unit/payloads/test_payload_store_security.py -q
# 5 passed
uv run pytest tests/unit/payloads/test_store.py tests/unit/payloads/test_payload_store_security.py -q
# 18 passed
uv run ruff check rampart/payloads/_store.py tests/unit/payloads/test_payload_store_security.py
uv run ruff format --check rampart/payloads/_store.py tests/unit/payloads/test_payload_store_security.py
uv run ty check rampart/payloads/_store.py tests/unit/payloads/test_payload_store_security.py
python -m compileall -q rampart tests
git diff --check |
There was a problem hiding this comment.
Pull request overview
This PR hardens payload collection load-time artifact handling by validating and containing deserialized artifact references so they cannot escape the collection’s artifacts/ directory after normalization and symlink resolution.
Changes:
- Added
PayloadStore._resolve_artifact_path()(and helper containment logic) to validate serialized artifact references during deserialization. - Updated deserialization to use the resolver and fail fast on invalid artifact paths before attempting to read.
- Added regression tests covering traversal, absolute/non-
artifacts/paths, missing artifacts, and symlink escape scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
rampart/payloads/_store.py |
Adds artifact-path resolution/containment checks and routes deserialization through them. |
tests/unit/payloads/test_payload_store_security.py |
Adds unit regression coverage for invalid serialized artifact paths and symlink escape handling. |
|
@Hinotoi-agent would you please fix the build? the checks are failing and Copilot also has recommendations |
Signed-off-by: hinotoi-agent <paperlantern.agent@gmail.com>
|
Fixed the failing build and remaining Copilot recommendation in
Validation:
The prior docs job failed while |
Summary
This is the focused follow-up requested in #57 (comment).
It keeps the load-time artifact containment hardening only: when deserializing a persisted payload collection, artifact references now have to remain under the collection's
artifacts/directory after normalization and symlink resolution.What changed
_resolve_artifact_path()inrampart/payloads/_store.pyfor deserialized artifact references..., or do not start withartifacts/.artifacts/directory.Scope notes
Payload.idvalidation.rampart/core/payload_ids.py._copy_file_artifact()orOneDriveSurface.upload_async().Test plan
Host-local:
Results:
5 passed18 passed617 passed, 5 skippedContainer validation:
Result: passed (
18 passed; ruff, ty, and diff whitespace checks passed).