Skip to content

fix: harden email agent security (allowlist, pickle, exceptions)#1040

Open
mattcarrollcode wants to merge 1 commit into
meta-llama:mainfrom
mattcarrollcode:fix/email-agent-security
Open

fix: harden email agent security (allowlist, pickle, exceptions)#1040
mattcarrollcode wants to merge 1 commit into
meta-llama:mainfrom
mattcarrollcode:fix/email-agent-security

Conversation

@mattcarrollcode
Copy link
Copy Markdown

Summary

  • Add ALLOWED_FUNCTIONS allowlist before globals() dispatch to prevent arbitrary code execution from LLM-crafted function names
  • Replace pickle-based OAuth token storage with JSON (google.oauth2.credentials)
  • Replace bare except: with except (json.JSONDecodeError, KeyError):
  • Fix type(result) == dict to isinstance(result, dict)
  • Update Google OAuth library version constraints

Motivation

The globals()[function_name] pattern dispatches to any function in the global scope based on LLM output. An adversarial prompt injection could cause execution of arbitrary functions. pickle.load() on token files is an arbitrary code execution vector.

Test plan

  • Verify email_agent.py passes syntax check
  • Verify the allowlist contains all functions actually called by the agent
  • Verify token storage works with JSON format

- Add ALLOWED_FUNCTIONS allowlist before globals() dispatch to prevent
  arbitrary code execution from LLM-crafted function names
- Replace pickle-based token storage with JSON (google.oauth2.credentials)
- Replace bare except: with except (json.JSONDecodeError, KeyError):
- Fix type(result) == dict to isinstance(result, dict)
- Update Google OAuth library version constraints
@meta-cla meta-cla Bot added the cla signed label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant