Skip to content

fix(security): validate RETAINDB_BASE_URL against SSRF before requests#4984

Open
maymuneth wants to merge 1 commit into
NousResearch:mainfrom
maymuneth:fix/retaindb-ssrf-url-validation
Open

fix(security): validate RETAINDB_BASE_URL against SSRF before requests#4984
maymuneth wants to merge 1 commit into
NousResearch:mainfrom
maymuneth:fix/retaindb-ssrf-url-validation

Conversation

@maymuneth

Copy link
Copy Markdown
Contributor

What does this PR do?

The RetainDB memory plugin reads RETAINDB_BASE_URL from an environment
variable and uses it directly in HTTP requests without any validation.

If RETAINDB_BASE_URL is set to an internal address (e.g.
http://169.254.169.254 on AWS, http://metadata.google.internal on GCP,
or any private network service), every memory read and write would silently
make requests to that internal address — a classic SSRF attack vector.

Fix

Added an is_safe_url() check in initialize() after reading
RETAINDB_BASE_URL. If the URL resolves to a private/internal address,
it is reset to the safe default endpoint with a warning log.

This is consistent with the SSRF protection already applied in:

  • tools/homeassistant_tool.py (HASS_URL)
  • tools/web_tools.py
  • tools/vision_tools.py
  • gateway/platforms/wecom.py

Type of Change

  • 🔒 Security fix (SSRF)

Checklist

  • Read the Contributing Guide
  • Commit messages follow Conventional Commits
  • Consistent with existing SSRF protection pattern in Hermes
  • No behavior change for legitimate RetainDB endpoints
  • ImportError handled gracefully

@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants