You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
User context sensitive env filtering uses substring matching #148
User context sensitive env filtering uses substring matching
Severity: Medium File:backend/app/core/user_context.py:95
The sanitized_subprocess_env function filters environment variables by checking if sensitive markers like "API_KEY", "AUTH_TOKEN", etc. appear in the variable name (case-insensitive). This can miss variants like APIKEY (no underscore) or api_key_custom.
_SENSITIVE_ENV_MARKERS= (
"API_KEY",
"AUTH_TOKEN",
"ACCESS_TOKEN",
"REFRESH_TOKEN",
"PRIVATE_KEY",
"PASSWORD",
"CREDENTIAL",
"CLIENT_SECRET",
)
defsanitized_subprocess_env(extra: Optional[dict[str, str]] =None) ->dict[str, str]:
"""Return the process environment without application or provider secrets."""sanitized= {}
forname, valueinos.environ.items():
upper_name=name.upper()
ifupper_namein_SENSITIVE_ENV_EXACT:
continueifany(markerinupper_nameformarkerin_SENSITIVE_ENV_MARKERS):
continuesanitized[name] =value
Why it matters
Sensitive credentials with non-standard naming conventions leak into subprocess environments, potentially exposing them to user-executed code.
Activity