The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills-guard): make the AWS key pattern case-sensitive
liuhao102485188b47f7c3
diff --git a/tests/tools/test_skills_guard.py b/tests/tools/test_skills_guard.pyindex 24fdaf6ce4c..64688dd6776 100644--- a/tests/tools/test_skills_guard.py+++ b/tests/tools/test_skills_guard.py@@ -197,6 +197,20 @@ class TestScanFile:findings = scan_file(f, "leak.md")assert any(fi.pattern_id == "gitlab_token_leaked" for fi in findings)+ def test_detect_aws_key_and_skip_base64_case_collision(self, tmp_path):+ f = tmp_path / "asset.md"+ # Concatenated so no contiguous key-shaped literal exists in this file+ # (GitHub push protection blocks AWS-key-shaped literals).+ real_key = "AKIA" + "IOSFODNN7EXAMPLE"+ # The base64 byte collision from #132155: case-folded AKIA + 16 chars inside an+ # encoded-asset stream — one such false critical hard-blocks a plugin install.+ collision = "d2FpA+swl+" + "AkIa" + "EwwIUrZwcQ2pTabf" + "u3JUxdW5bl60714bP"+ f.write_text(f"use {real_key} here\nembedded asset: {collision}\n", encoding="utf-8")+ findings = scan_file(f, "asset.md")+ keys = [fi for fi in findings if fi.pattern_id == "aws_access_key_leaked"]+ assert len(keys) == 1+ assert real_key in keys[0].match+def test_detect_markdown_injection(self, tmp_path):f = tmp_path / "bad.md"f.write_text(diff --git a/tools/skills_guard.py b/tools/skills_guard.pyindex 420fbb51645..e947567e3e3 100644--- a/tools/skills_guard.py+++ b/tools/skills_guard.py@@ -426,7 +426,10 @@ THREAT_PATTERNS = [(r'sk-[A-Za-z0-9]{20,}', "openai_key_leaked", "critical", "credential_exposure", "possible OpenAI API key in skill content"),(r'sk-ant-[A-Za-z0-9_-]{90,}',"anthropic_key_leaked", "critical", "credential_exposure", "possible Anthropic API key in skill content"),- (r'AKIA[0-9A-Z]{16}', "aws_access_key_leaked", "critical", "credential_exposure", "AWS access key ID in skill content"),+ # AWS access key IDs are all-caps by spec. Scoped case-sensitive — the table compiles with+ # IGNORECASE, and a case-folded AKIA+16 inside a base64-encoded asset is a byte collision,+ # not a key (#132155); one such false critical hard-blocks the whole plugin install.+ (r'(?-i:AKIA[0-9A-Z]{16})', "aws_access_key_leaked", "critical", "credential_exposure", "AWS access key ID in skill content"),(r'glpat-[A-Za-z0-9_\-]{20,}',"gitlab_token_leaked", "critical", "credential_exposure", "GitLab personal access token in skill content"),# ── Additional prompt injection: jailbreak patterns ──