fix: harden dashboard profile and artifact boundaries - #69
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69733836dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| with open(resolved_path, "r", encoding="utf-8", errors="ignore") as f: | ||
| line1 = f.readline() | ||
| line2 = f.readline() | ||
|
|
||
| prefix = f.read(ARTIFACT_HEADER_PREFIX_BYTES) |
There was a problem hiding this comment.
Read the bounded artifact prefix in binary mode
When an allowed artifact contains many invalid UTF-8 bytes, TextIOWrapper.read(8192) with errors="ignore" keeps consuming input until it produces 8192 decoded characters or reaches EOF, so this can still read an arbitrarily large file and block every snapshot that verifies it. For example, reading a 2 MiB file of 0xff this way consumes all 2 MiB while returning an empty string; read 8192 bytes from a binary stream first and then decode that fixed prefix.
Useful? React with 👍 / 👎.
| line2 = f.readline() | ||
|
|
||
| prefix = f.read(ARTIFACT_HEADER_PREFIX_BYTES) | ||
| lines = prefix.splitlines() |
There was a problem hiding this comment.
Restrict artifact header splitting to real newlines
When a corrupt or hostile artifact places a vertical tab, form feed, NEL, or Unicode line separator between the markers, str.splitlines() treats that character as a line boundary and reports VERIFIED_COMPLIANT, even though the required STATUS: and ARTIFACT: markers are on one physical line. The previous readline() implementation rejected these inputs, so split the bounded prefix only on the newline forms accepted by the file format.
Useful? React with 👍 / 👎.
Summary
Verification
python -m pytest tests/test_profiles.py tests/test_dashboard_snapshot.py tests/test_triage_api.py -qpython -m pytest tests -qpython -m py_compile agent_sensorium/*.py scripts/*.pygit diff --checkSupersedes the still-relevant dashboard boundary findings from stale security and broad proposal branches without adopting their conflicting changes.