Security hardening: credential storage, input validation, and access controls - #515
Closed
nobugpal wants to merge 1 commit into
Closed
Security hardening: credential storage, input validation, and access controls#515nobugpal wants to merge 1 commit into
nobugpal wants to merge 1 commit into
Conversation
…, and access controls
- Encrypt sensitive config values (API keys, tokens, cookies) at rest
using a machine-local derived key with integrity verification
- Restrict Config.get() environment variable fallback to an explicit
allowlist, preventing unintended leakage of unrelated env vars
- Add URL validation (SSRF protection) to WebChannel.read() before
proxying requests to the Jina Reader service
- Add file extension validation for local audio file paths in
transcribe() – only recognized audio formats are accepted
- Add argument separator guard ('--') before user-supplied URL in
yt-dlp subprocess call for defense-in-depth
- Document cookie extraction scope in privacy notice
Backward compatible: existing unencrypted configs continue to work;
encrypted fields are transparently decrypted on read.
All existing tests pass.
Owner
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
This PR addresses several hardening opportunities identified during a code audit of Agent-Reach. The changes improve credential protection, restrict configuration access, and add input validation boundaries — all without breaking backward compatibility.
Changes
Credential Storage (
config.py)Config.get()— no API changes for callersEnvironment Variable Access (
config.py)Config.get()now only falls back to an explicit allowlist of known env var names, preventing unintended leakage of arbitrary environment variablesURL Validation (
channels/web.py)_validate_url()to block requests to private IPs, loopback addresses, cloud metadata endpoints, and internal hostnames before proxying to Jina ReaderInput Validation (
transcribe.py)transcribe()must now have a recognized audio extension (.wav,.mp3,.m4a, etc.) — non-audio files are rejected before processing"--") before user-supplied URL in the yt-dlp subprocess callPrivacy (
cookie_extract.py)Backward Compatibility