fix(security)!: temporarily disable /help_docs command (#2445)#2451
Conversation
/help_docs lets an untrusted PR commenter override the git clone target and, due to weak clone-URL host validation, exfiltrate the git provider token to an attacker-controlled host. As an immediate mitigation, unregister the command so it can no longer be invoked, ahead of the full validation fix. Re-enable by restoring the `help_docs` entry and its import once the hardening PR is merged.
Code Review by Qodo
Context used 1. Test depends on global settings
|
PR Summary by QodoTemporarily disable /help_docs command to mitigate token exfiltration risk WalkthroughsDescription• Unregister /help_docs to prevent invocation while clone-target validation is hardened. • Add regression tests ensuring /help_docs is unknown and not routed. • Document re-enable steps inline, referencing issue #2445. Diagramgraph TD
U["PR commenter"] --> H["PRAgent._handle_request()"] --> M["command2class (no help_docs)"] --> X["Unknown command"] --> R["Reject request (False)"]
High-Level AssessmentThe following are alternative approaches to this PR: 1. Feature-flag gate /help_docs
2. Ship minimal host validation hotfix instead of disabling
Recommendation: For an immediate mitigation, fully unregistering File ChangesBug fix (1)
Tests (1)
|
Summary
Immediate mitigation for #2445.
/help_docsaccepts an untrusted runtime override of the clone target (--pr_help_docs.repo_url=...) and, because the clone-URL host validation only checks substring containment, the git provider token can be embedded into a clone URL pointing at an attacker-controlled host (e.g.github.com.attacker.tld) — leakingGITHUB_TOKEN.This PR is a stopgap: it unregisters the
/help_docscommand so it can no longer be invoked, to be merged ahead of the full fix. An incoming/help_docsnow resolves to an unknown command and is rejected.The complete hardening (exact host validation across all providers + blocking the runtime override) is in #2450; this command should be re-enabled as part of that work.
Changes
help_docsentry (and its import) fromcommand2classinpr_agent/agent/pr_agent.py, with a comment pointing at PR-Agent /help_docs allows untrusted commenters to override git clone target and exfiltrate GITHUB_TOKEN via weak hostname validation #2445 / re-enable instructions.tests/unittest/test_help_docs_disabled.pyasserting the command is unregistered and not routed.Re-enable
Restore
"help_docs": PRHelpDocsand its import, and delete the stopgap test, once #2450 (or equivalent) lands.