
How do security-conscious teams allow AI to work on private repos while keeping an audit trail of what it ran and changed?
Security-conscious teams want the same thing from AI that they demand from humans touching prod: scoped access, clear blast radius, and an audit trail you can trust. Letting AI work on private repos without losing control is less about “which model” and more about the runtime, permissions, and logging around it.
Quick Answer: Security-conscious teams let AI work on private repos by running agents in a containerized sandbox with scoped credentials, routing all repo access through that runtime, and persisting a complete audit trail of commands, API calls, and diffs. They enforce SSO/RBAC, restrict network and data access, and require human review of every artifact (PRs, commits, patches) before anything merges.
Why This Matters
Once an agent can clone a private repo, it’s effectively inside your SDLC. That’s where most “cool demo” AI tools break down for real enterprises: they assume full GitHub access, no clear boundary between model and code, and little to no auditability. For regulated teams, that’s a non-starter.
Getting this right means you can:
- Offload outer-loop work—reviews, test fixes, dependency bumps, vulnerability patches—without giving up control.
- Confidently prove to security, legal, and auditors what ran, where it ran, and exactly what changed.
- Scale from a single experimental agent to thousands of parallel runs as infrastructure, instead of a risky sidecar tool.
Key Benefits:
- Scoped blast radius: The agent runs in an isolated sandbox with limited credentials, not as a superuser in your repos.
- Full audit trail: Every command, file change, and Git operation is recorded and replayable.
- Operational leverage at scale: You can safely parallelize repo-wide maintenance, refactors, and fixes because execution is governed and observable.
Core Concepts & Key Points
| Concept | Definition | Why it's important |
|---|---|---|
| Containerized sandbox runtime | An isolated Docker/Kubernetes environment where the AI agent runs, with controlled network, filesystem, and credentials. | Creates a hard boundary between the agent and the rest of your systems, so a mistake or prompt injection affects a sandbox, not prod. |
| Scoped credentials & RBAC | Minimal Git tokens, per-repo or per-org scopes, enforced via SSO/SAML and role-based access control. | Limits what an agent can touch and lets you prove “who could do what” when auditors ask. |
| Deterministic, replayable runs | Every agent run is logged with inputs, steps, and outputs so you can re-run the same task and get the same result. | Turns autonomy into something you can inspect, debug, and certify as production-grade instead of a black box. |
How It Works (Step-by-Step)
At a high level, secure teams wrap AI in the same controls they use for CI/CD: sandboxed execution, least-privilege access, and end-to-end observability. Here’s what that looks like with a platform like OpenHands.
-
Establish a secure runtime boundary
- Run agents in containerized sandboxes (Docker or Kubernetes) in your own VPC or a trusted cloud.
- Lock down the environment:
- No direct access to developer laptops or arbitrary internal services.
- Explicit egress rules (e.g., only Git, artifact stores, and approved APIs).
- Read/write limited to a workspace directory where the repo is checked out.
- Treat this like production infrastructure, not a browser plugin: IaC-managed, monitored, and patched.
-
Attach scoped repo access and identity
- Use SSO/SAML to authenticate users into the platform and tie each agent run to a human identity.
- Issue narrowly scoped Git credentials:
- Repo-level or org-level PATs with least privilege (e.g., no “admin:org” just to clone code).
- Optional read-only tokens for analysis-only tasks; separate tokens for write/PR creation.
- Enforce RBAC:
- “Can run agents on these repos.”
- “Can approve agent-generated PRs.”
- “Can configure credentials/models.”
-
Log every action and artifact
- Record the full execution trace for each run:
- Commands executed in the sandbox (e.g.,
git clone,npm test,mvn dependency:tree). - Files read and written.
- Git operations (branch created, commits, pushes).
- Commands executed in the sandbox (e.g.,
- Capture the artifacts:
- Diffs/patches.
- Generated tests, docs, or release notes.
- PRs and issue comments.
- Make these traces accessible via a Web GUI and/or API so security and leads can inspect runs, not just outcomes.
- Record the full execution trace for each run:
-
Enforce human review before merge
- Route agent output into standard SDLC workflows:
- PRs with clear diffs and descriptions.
- Comments on existing PRs (review feedback, test fixes).
- Require human approvals at the repo or branch level:
- CI + code owners + security signoff where required.
- Use OpenHands’ GUI or your Git provider’s UI to review what the agent did before anything gets merged.
- Route agent output into standard SDLC workflows:
-
Run headlessly with governance
- Once patterns are trusted, run agents “headlessly” from CI/CD, cron, or internal systems:
- Scheduled dependency upgrades.
- Recurring vulnerability remediations.
- Automated test stabilization.
- Keep the same sandbox + audit discipline:
- Every automated run is logged.
- Every change still flows through PRs with approvals.
- Track metrics over time: success rates, bug fix times, diff sizes, and “outer loop” workload reduction.
- Once patterns are trusted, run agents “headlessly” from CI/CD, cron, or internal systems:
Common Mistakes to Avoid
-
Letting the AI tool own the credentials:
- Many SaaS copilots ask for broad GitHub access and manage tokens themselves.
- How to avoid it: Keep tokens in your own secrets manager or platform (like OpenHands), inject them into sandboxed runtimes, and never hand a long-lived org token to a third-party UI.
-
Treating AI execution like chat, not infrastructure:
- If you can’t see what commands ran, what files changed, and where it executed, you’re flying blind.
- How to avoid it: Standardize on a platform that treats agents like jobs in a CI system—logged, replayable, and tied to identity—not like ephemeral chat replies.
Real-World Example
Imagine a security-conscious fintech company with dozens of microservices and a growing vulnerability backlog. Every week, AppSec opens Jira tickets for dependency upgrades and CVE patches. Engineering teams are overloaded; fixes slip, and audit findings pile up.
They deploy OpenHands inside their VPC, running agents in Kubernetes-managed sandboxes:
- Authentication & authz: Engineers authenticate via SSO. RBAC controls which repos each team’s agents can touch.
- Repo access: The platform injects per-repo Git tokens into the sandbox. No engineer, and no external service, ever sees the raw tokens.
- Execution: A scheduled job kicks off weekly:
- For each repo, an agent clones the repo in a sandbox, runs a security scanner, and attempts to:
- Upgrade vulnerable dependencies.
- Regenerate lockfiles.
- Run tests and linters.
- On success, the agent pushes a branch and opens a PR with:
- A human-readable summary of changes and CVEs addressed.
- A link to the full execution trace: commands, logs, and diffs.
- For each repo, an agent clones the repo in a sandbox, runs a security scanner, and attempts to:
- Review & compliance: Engineers review PRs via GitHub; AppSec uses OpenHands’ GUI to:
- Inspect what the agent ran.
- Confirm that only approved scanners and commands were used.
- Export logs for audit if required.
Over time, they scale from a handful of repos to hundreds. The pattern stays safe because nothing about the trust model changes: same sandbox boundary, same scoped tokens, same audit trail—just more parallel agents.
Pro Tip: When you first roll this out, start with read-only analysis runs (e.g., “summarize security posture,” “list outdated dependencies”) and review the full execution traces. Once you’re confident in the agent’s behavior and your sandbox policies, then enable write/PR capabilities.
Summary
Security-conscious teams don’t avoid AI—they insist on running it like any other critical piece of infrastructure. They let AI work on private repos by:
- Executing agents in containerized sandboxes they control.
- Using SSO/SAML, RBAC, and scoped Git credentials to define a tight blast radius.
- Logging every command, file change, and Git operation so runs are fully auditable and replayable.
- Requiring human review of agent-generated artifacts—PRs, diffs, test changes—before merge.
OpenHands was built around that model: open source, model-agnostic, and designed to run in secure, sandboxed runtimes you control, from a single agent run to thousands in parallel. It turns “autonomous” work into something you can see, inspect, and re-run deterministically.