Skip to content

[SECURITY] Replace global os.environ overlay with async-safe per-org credential context #63

Done

Description

@OkiriGabriel

Problem

Multi-tenant credential isolation uses org_credentials() to temporarily mutate process-global os.environ. Collectors and tools then read keys via os.getenv().

Under FastAPI concurrent request handling, org A API keys can leak into org B in-flight requests. The queue worker, webhooks, Slack actions, and MCP calls share one DevOpsAgent singleton in the same process.

execute_approved_action() also runs without org scoping.

Impact

Cross-tenant credential bleed in multi-org deployments. A webhook for org acme could cause the agent to use contoso GitHub token or Anthropic key.

Proposed solution

  1. Introduce an explicit CredentialContext passed through agent, collectors, and tools
  2. Stop mutating os.environ for per-request org switching
  3. Wrap execute_approved_action with org lookup and scoped credentials
  4. Add concurrency tests: two orgs with distinct keys, overlapping requests, assert no cross-use

References

  • services/org_context.py
  • api/server.py (queue worker, singleton agent)
  • agent/core.py
  • collectors/.py, tools/.py

Activity

  1. added
    enhancement
    security
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions