security: escape untrusted model output in HTML reports, harden fetch/report paths - #25
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
security: escape untrusted model output in HTML reports, harden fetch/report paths#25devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Security pass over the codebase. Four issues fixed; all inputs involved are attacker-influenceable (LLM output is derived from third-party client source code that PRSpec fetches, so prompt injection in a scanned repo can steer what lands in a report).
1. HTML injection in the single-client report (highest severity).
_generate_html_reportescaped issue fields but interpolated the narrative,status,file_name, and theReportMetadatafields raw. The narrative embedsresult["summary"]verbatim, so any model-produced<script>executes when the report is opened locally (file:// origin, reads local files, exfiltrates). Now every interpolation goes throughhtml.escape; same forrow.verdict/ KPI numbers in the differential report.2. Report filenames could escape
output/. Filenames were built frommetadata.client(a CLI value) andmetadata.eip_number, so--client ../../foowrote outside the output directory. Added_slug()over both components.3. Cache filenames could escape the cache dir.
SpecFetcher/CodeFetcherbuilt cache keys withpath.replace('/', '_')only —branch,owner,repowere unsanitized. Replaced with a shared_cache_name()that maps everything outside[A-Za-z0-9._-]to_.4.
clone_repository()argument injection.url/branchwere passed straight togit clone, soext::sh -c ...or a--upload-pack="URL" is command execution. Added_validate_clone_url(scheme allowlist, no leading-) and_validate_branch(plain ref names only).Also added request timeouts (
DEFAULT_TIMEOUT = 30) to everysession.getin both fetchers — previously a slow/hostile endpoint hung the CLI indefinitely.New
tests/test_report_security.pycovers all four (156 passing, ruff clean).Reviewed and found clean
No hardcoded secrets in the tree or in git history (
.env.exampleholds placeholders only). No SQL, no HTTP server, no CORS config, no debug endpoints, no auth surface — PRSpec is a local CLI/library.yaml.safe_loadalready used.pip-auditreports no known-vulnerable dependencies.Known residual risks (not fixed here)
requirements.txtare fully unpinned (requests,pyyaml,click, ...) with no floors or hashes; a compromised upstream release is installed silently.Link to Devin session: https://app.devin.ai/sessions/99d7c66d95a64b73b3c0a0c4686266a7
Requested by: @Fosurero