harden(api): escape HTML in email alerts + tighten events-endpoint authz#10
Open
mikeumus wants to merge 1 commit into
Open
harden(api): escape HTML in email alerts + tighten events-endpoint authz#10mikeumus wants to merge 1 commit into
mikeumus wants to merge 1 commit into
Conversation
Closes the two flagged-for-later items. 1. HTML escaping (alerting.ts): the email channel renders details into an HTML body, and some fields are user-controlled — `accountName` traces to req.body.name at cloud-account creation, and the cloud-monitoring path's `summary` embeds it. So the unescaped interpolation WAS reachable (via the core cloud path, not agent-guard). Adds escapeHtml() applied to every string interpolation in the email HTML (summary, provider, accountName, violation serviceName/metricName/values, actionsTaken). Audited the other channels: Slack/Discord/PagerDuty/webhook all transmit via JSON (values render as text), so only the email sink needed it. +1 regression test asserting a <script> payload is neutralized to <script>. 2. Events authz (agent-guard route): POST /agent-guard/events now requires kill_switch:trigger (owner/admin/member) instead of cloud_accounts:read — an agent block IS a kill-switch action, so reporting one is a write that viewers shouldn't make. GET stays cloud_accounts:read (it's a read). Full API suite: 845 passed / 12 skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the two items flagged during the agent-guard security pass.
1. HTML escaping in email alerts
The finding got more serious on investigation. The email channel renders alert
detailsinto an HTML body, andaccountNametraces back toreq.body.nameat cloud-account creation — user-controlled. The cloud-monitoring alert path embeds that name in bothsummaryandaccountName. So the unescaped interpolation was reachable — not via agent-guard's fields (as first thought), but via the core cloud path.escapeHtml()applied to every string interpolation in the email HTML body (summary,provider,accountName, violationserviceName/metricName/values,actionsTaken).JSON.stringify(values render as text, not markup) — only the email sink needed escaping. Slack/Discord markdown from a crafted string is cosmetic, not a security issue.<script>payload in accountName/serviceName/summary is neutralized to<script>.2. Events endpoint authorization
POST /agent-guard/eventsnow requireskill_switch:trigger(owner/admin/member) instead ofcloud_accounts:read— an agent block is a kill-switch action, so reporting one is a write that viewers shouldn't make.GETstayscloud_accounts:read(it's a read). Role enforcement is covered by the existingpermissions.test.tsmatrix.Verification
Full API suite: 845 passed / 12 skipped (+1 new).
tscclean.🤖 Generated with Claude Code