Repository navigation
feat(egress): Audit every egress decision and MCP tool call - #3108
Conversation
…n write audits Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bdd0df0. Configure here.
|
15 screenshot changes — 15 changed · 0 added · 0 removed Review screenshots in Frameshift Show 9 more changed screenshots |
|
anything we can do here to ensure the audit trails are generally always present? even if they dont contain full information etc (could just be domain/path/actor and whether it was allowed or denied, and why?) |
|
Yes. 2301741 gives every egress outcome the same minimal record:
One query now shows the whole trail: Two things to decide:
|
This comment has been minimized.
This comment has been minimized.
|
i think we can audit every mcp tool call too why not |
|
Done in ec37a6c. Every successful MCP tool call now emits the
|
|
upate the pr description |
Review summaries got no 👀. David's review bodies on #3111, #3109, and #3091 have no reaction, but his conversation comment on #3108 does. **Root cause:** `pullRequestFeedbackTarget` marked only `pull_request.comment.created` and `pull_request.review_comment.created`. Review events set no `commentId` or `commentKind`. GitHub also has no REST reactions endpoint for a review body. **Fix:** every comment on a pull request now gets the same behavior: conversation comments, inline review comments, and review bodies. - A submitted review with a non-blank body sets `commentId` (the review id) and `commentKind: "review_body"` on its event data. - The webhook marks the first pull request event that has a feedback target. An approval with a body is also sent as `review.commented`, and it gets one reaction. For `review_body`, the webhook reads the review's `node_id` and sends GraphQL `addReaction` (`EYES`). - All comment events share one feedback guidance: call `github_updatePullRequestFeedback` with `repo`, `pull_request`, `comment_id`, and `comment_kind` from Verified details. - `github_updatePullRequestFeedback` requires `pull_request` for every kind. It checks that the bot authored that pull request and that the comment is on it, then replaces Junior's state reaction. Review bodies use GraphQL `reactionGroups.viewerHasReacted`, `removeReaction`, and `addReaction`. `reaction_id` is now optional, because GraphQL gives no id for a reaction that already exists. - The egress policy allows `AddReviewReaction` and `RemoveReviewReaction` only for the host operation `github.pull.review-reaction.update:<repo>`. **Remaining risk:** the GraphQL calls are tested only against fakes. `viewerHasReacted` depends on the installation credential that the egress read grant picks today. The webhook adds one REST read for each review with a body. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A0f0c2da6c27982200b4d351cdb09043e --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A0f0c2da6c27982200b4d351cdb09043e) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A0f0c2da6c27982200b4d351cdb09043e/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
Junior pushes with the GitHub App installation token, so every push lands as the App, whoever asked. Before Automations move to system credentials, the egress policy should make sure that identity can never change a repository's default branch. Junior proposes changes through pull requests. Stacked on #3108. How it works: - For a `git-receive-pack` POST, core reads the pkt-line ref update commands up to the first flush, before push options and pack data. It skips `shallow` lines and the capabilities after the NUL. Grant hooks get the result as `request.gitPush`: either `{ kind: "commands", updates: [{ ref, deletes }] }` or `{ kind: "unreadable", reason }`, where the reason is `gzip`, `signed`, `unterminated`, or `malformed`. This is Git protocol, so any plugin can use it. - The GitHub plugin refuses unreadable pushes and looks up the repository's default branch with a metadata-only installation token, cached for 10 minutes. - It refuses the whole push when any ref is the default branch (update, create, or delete) or is outside `refs/heads/` (tags, notes, and so on). It also refuses a failed default-branch lookup. A lone flush, which Git sends to probe auth before a large push, passes without a lookup. - Allowed pushes add `app.github.refs`, `app.github.default_branch` and `app.github.default_branch_targeted` to the write audit. Denials carry the same facts on `sandbox.egress.policy.denied` through a new optional `auditAttributes` on `EgressPolicyDenied`. - REST and GraphQL already cover the other paths: ref writes, the contents API, merges, and every GraphQL mutation except three host-tool ones are already unsupported writes. No change there. Agent experience: git shows only `RPC failed; HTTP 403` for a refused push. Every egress policy denial now also records a `permission_denied` signal with `source: "policy"`. The bash result then says Junior's policy refused the request, gives the reason, and says not to retry or ask for more access. This applies to the existing tool-routing denials too, not just pushes. The `github-code` skill references say the same. Scope: the rule applies to every turn, not only Automations, because every push uses the App identity. Fast revert is unaffected: Junior only adds the label, and the push to the default branch happens in GitHub Actions, outside Junior egress. Protected branches other than the default rely on GitHub rulesets. Whether the Junior GitHub App is on any ruleset bypass list is unverified. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A25af7a2633ca7bdc8b617fbe7af140cd --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A25af7a2633ca7bdc8b617fbe7af140cd) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A25af7a2633ca7bdc8b617fbe7af140cd/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

First step toward moving Automations to system credentials: before we change which credential a run uses, the audit trail has to show every decision and whose authority it used.
Egress
Each egress request that reaches credential selection, and each sandbox request the proxy refuses first, ends in exactly one event with
app.egress.policy.decision(allowedordenied), the host, path, method, and the run Source when Junior could read the credential context. A denial addsapp.sandbox.egress.policy.reason.sandbox.egress.upstream.requestedis now an audit event (app.log.audit:true) for every forwarded read and write, so Sentry keeps all of them in production. Before this, only write grants were kept.sandbox.egress.provider.unresolved,sandbox.egress.credential_context.unauthorized,sandbox.egress.request_body.unreadable,sandbox.egress.policy.denied,sandbox.egress.credential.needed,sandbox.egress.credential.unavailable, andsandbox.egress.transform.missing.The allowed event also records:
app.credential.account:actorwhen the lease holds a person's OAuth token (the Actor's, or a delegated credential subject's).appwhen it holds a credential Junior owns, such as a GitHub App installation token or a deployment key.app.source.kind,app.task.id,app.task.run.id: the run Source and its Automation run. Before this,app.task.idappeared only when creator credentials were delegated, so system-mode Automation writes could not be traced to their Automation. These values travel in the signed sandbox egress token as telemetry only. They grant nothing.auditAttributesfield onPluginGrant, limited toapp.<provider>.*keys. GitHub setsapp.github.repository. That includes host GraphQL mutations, where the repository comes from the operation, not the URL.MCP
Every successful MCP tool call, in every turn, is now a
mcp.tool_call.completedaudit event with the run Source andapp.credential.account. That covers Linear's MCP writes.mcp.tool_call.failedcarries the same Source facts.This removes
mcp.audit-tools: plugin-apiPluginMcpConfig.auditTools, the manifest schema and config patch, and the Notionplugin.yamllist. That is a breaking change to the published plugin-api type. junior-prod does not set it. A staleaudit-toolskey in aplugin.yamlis ignored, because the MCP manifest schema passes unknown keys through.Not here
app.github.refsand the default-branch flags come with the push guard in #3111, which parses thegit-receive-packrequest.I used the existing
app.task.run.idname (TELEMETRY.md: "automation / one run") rather than addingapp.automation.run_id.TELEMETRY.md has recipes for every egress decision, credentialed writes, and MCP tool calls.
via @dcramer.
--
View Session [Sentry]