security: fix SSRF, auth bypass, prompt injection, and SQL injection vulnerabilities - #159
Open
failsafesecurity wants to merge 1 commit into
Conversation
…vulnerabilities Fixes 4 high-severity security issues found during whitebox audit: 1. SSRF via admin skill import URL (AGNT-001) - Add url_validation.py with private IP blocklist checking - Apply validate_url_not_private() before all admin URL fetches - Opt-in via SSRF_VALIDATION_ENABLED env var (default: False) 2. Auth bypass when AUTH_ENABLED unset (AGNT-002) - Change AUTH_ENABLED default from None to 'true' - Use explicit boolean parsing instead of truthy check - Prevents unauthenticated access if env var is accidentally unset 3. Prompt injection via extract_prompt (AGNT-003) - Wrap extract_prompt in XML delimiters with safety note - Strip prompt-breaking sequences from user input - Enforce 500-char length limit on extract_prompt 4. LLM-generated SQL executed without validation (AGNT-004) - Add _validate_generated_sql_safety() with keyword blocklist - Block DROP, DELETE, ALTER, CREATE, INSERT, UPDATE, TRUNCATE, GRANT, REVOKE - Opt-in via SQL_SAFETY_CHECK_ENABLED env var (default: False) All new checks are opt-in by default to avoid breaking existing deployments. Set SSRF_VALIDATION_ENABLED=true and SQL_SAFETY_CHECK_ENABLED=true to enable.
Author
|
Hi - just a friendly ping on this security fix. Happy to adjust the approach if you have concerns about backwards compatibility or scope. If this isn't the right format for security reports, I'm happy to resubmit via a private security channel. |
Author
|
Friendly follow-up on this security PR. If you'd like any part split into smaller changes or want a different disclosure path, I can adapt quickly. |
Author
|
Hi maintainers — friendly follow-up on this consolidated security fix PR. Happy to split it into smaller PRs or adjust the approach if that would help with review. |
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.
Security Fixes — 4 High-Severity Vulnerabilities
During a whitebox security audit of the Heurist Agent Framework, we identified 4 high-severity and 2 medium-severity vulnerabilities. This PR addresses the 4 high-severity issues with opt-in fixes.
AGNT-001: SSRF via Admin Skill Import URL (High)
The
/admin/skills/importendpoint fetches arbitrary URLs without validating against private IP ranges. An attacker withINTERNAL_API_KEYcan access cloud metadata (169.254.169.254) or internal services.Fix: Added
url_validation.pywithvalidate_url_not_private()that resolves hostnames and blocks private/link-local/cloud-metadata IPs. Applied before all admin URL fetches. Opt-in viaSSRF_VALIDATION_ENABLED=true.AGNT-002: Auth Bypass When AUTH_ENABLED Unset (High)
AUTH_ENABLED = os.getenv("AUTH_ENABLED")with no default means auth is completely disabled if the env var is unset — any user can execute agents without API keys or credit deduction.Fix: Changed default to
"true"with explicit boolean parsing:os.getenv("AUTH_ENABLED", "true").lower() in ("true", "1", "yes").AGNT-003: Prompt Injection via extract_prompt (High)
The
extract_promptparameter is directly concatenated into the system prompt without sanitization, allowing prompt injection to override agent behavior.Fix: Wrapped
extract_promptin XML delimiters with a safety note, stripped prompt-breaking sequences ([INST],</s>,###, etc.), and enforced a 500-char length limit.AGNT-004: LLM-Generated SQL Executed Without Validation (High)
The
space_and_time_agentsends user NL queries to an LLM to generate SQL, then executes it without any validation. Prompt injection can produce destructive SQL (DROP TABLE, DELETE, etc.).Fix: Added
_validate_generated_sql_safety()that blocks destructive keywords (DROP, DELETE, ALTER, CREATE, INSERT, UPDATE, TRUNCATE, GRANT, REVOKE). Opt-in viaSQL_SAFETY_CHECK_ENABLED=true.Remaining Medium Findings (not in this PR)
server_urlis user-controllableDesign Principles
SSRF_VALIDATION_ENABLED=trueandSQL_SAFETY_CHECK_ENABLED=trueto enableTesting
os.getenv("AUTH_ENABLED", "true")returns"true"when unset, which parses toTrueWe are happy to adjust the approach based on maintainer feedback. Happy to split into separate PRs if preferred.