feat(rules): add AI600-AI900 security rules for agents, RAG, API keys, and output handling - #93
Open
mmustafasenoglu wants to merge 2 commits into
Open
Conversation
…API keys, and output handling Adds 18 new rules covering: - AI600: Unsafe agent behavior & tool poisoning (web browsing, subprocess, file write, indirect injection) - AI700: RAG security (embedding poisoning, context overflow, untrusted sources) - AI800: API key management (OpenAI, Anthropic, Cohere hardcoded keys) - AI900: Output handling & DoS (YAML unsafe load, JSON DoS, exec/eval of LLM output, XSS) Also adds 4 new taint sources/sinks for RAG and agent web tool flows. Closes ParzivalHack#91
- Remove AI601/AI603/AI604: line-based regex cannot establish agent context; SSRF and file access already covered by AI501/AISK08 and AI502/AISK09 taint analysis - Remove AITS12/AISK11: AITS12 tainted every requests.get response, AISK11 duplicated the existing AISK08 sink - AI602: require shell=True instead of flagging all subprocess usage - AI702: pattern now checks score_threshold (was checking top-k count) - AI902/AI903/AI904: narrow patterns to LLM-output variables; drop broad .*response|.*output|.*completion alternatives that matched any line containing those words - AI904: exclude sanitized output (sanitize|bleach) - AITS11: fix malformed function path, match instance calls via .similarity_search - Add negative tests: plain HTTP clients, subprocess without shell, plain json.loads, other embedding models, sanitized HTML, top-k without threshold, plain eval, multiline taint flow - Taint tests: trusted constants stay untainted, no duplicate AI501/AI601 findings
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
Adds AI600-AI900 security rules for detecting vulnerabilities in AI/LLM-related code:
Changes
pyspector/rules/ai_security.pyReview Status
Previously reviewed by @desimetallica — addressed all feedback:
confidence = "Low"where appropriateFixes #92 (reopened per maintainer request — volunteers need time, thank you for patience!)