fix(agent): sanitize scene IDs in wire capture and transcript paths (#370) - #373
Open
Adityakk9031 wants to merge 1 commit into
Open
fix(agent): sanitize scene IDs in wire capture and transcript paths (#370)#373Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
…obocurve#370) LLMAgentPolicy was building side-car paths from the raw scene ID, which is unvalidated task-author input. Hostile or unusual IDs (e.g., featuring path separators or parent directory segments) could lead to directory traversal. Resolve this by sanitizing scene IDs with the \_safe()\ helper (equivalent to core's FrameStore/eval.py sanitization) when constructing filenames and metadata pointers for both wire captures and transcripts. Add test coverage ensuring traversal is blocked and files reside under the correct run directories.
Contributor
Author
|
@jeqcho have a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #370
Description
LLMAgentPolicywas constructing transcript and wire capture filesystem paths from the rawscene_idvalue. Sincescene_idis unvalidated task-author input, unusual strings or directory traversal patterns could write files outside the intended log directories.This PR sanitizes the scene IDs using the plugin's
_safehelper (matching core'sFrameStoreandeval.pysanitization logic) before constructing side-car paths and metadata pointers.Changes
inspect-robots-agent:_safefrom_captureinpolicy.py.on_trial_startto pass_safe(scene_id)instead ofscene_idto_capture.begin_trial.on_trial_endto construct thetrial_idtranscript filename with_safe(record.scene_id).test_scene_id_sanitization_prevents_directory_traversalintests/test_policy_e2e.pyto assert that paths are safely resolved within the target run directory and directory traversal is blocked.CHANGELOG.md.Verification
pytest plugins/inspect-robots-agent/tests-> 486 passed.ruff check plugins/inspect-robots-agent-> Passed.ruff format --check plugins/inspect-robots-agent-> Passed.