Repository navigation
fix: harden webhook auth and CLI argument injection vectors - #2595
Conversation
Previously, get_body() only validated x-hub-signature-256 when GITHUB.WEBHOOK_SECRET was set. A misconfigured deployment (or one that forgets to set the secret) silently accepted every webhook as authentic, allowing any internet caller to trigger expensive AI commands against arbitrary PRs. Now the endpoint returns 403 when the secret is missing, and signature verification is performed on every authenticated request. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
handle_line_comments built a CLI command string by interpolating attacker-controlled webhook fields (path, side, comment_id, question, start_line, end_line) unescaped. Any of these that contained whitespace or a leading '--' was split into separate CLI arguments by the downstream shlex lexer and update_settings_from_args applied them to global settings, bypassing the per-arg blacklist. Quote every value with shlex.quote so the lexer keeps each value as a single argument regardless of its content. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
…extra_config_url extend the forbidden CLI argument blacklist so an attacker cannot override LocalGitProvider's filesystem write targets (local.description_path / local.review_path / local.improve_path) or the remote extra_config_url via comment-driven CLI argument injection. The blacklist uses substring matching against the lowercased argument, so adding the bare keys also blocks the section-prefixed variants (e.g. 'local.description_path'). Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
The marketplace webhook handler previously echoed the entire parsed body to logs and went through get_body(), which now requires a configured webhook secret. Since marketplace webhooks do not use the same x-hub-signature-256 header, this handler must parse the body directly. It is still a no-op aside from logging, but stop logging the raw body so a forged request cannot inject arbitrary content into logs (e.g. impersonating other actors, breaking log formatters, or poisoning downstream log analysis). Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
The Bitbucket webhook handler decoded the iss claim from the JWT header before signature verification, then used that same unverified iss as the audience parameter in jwt.decode(). An attacker who controlled a single installation could mint a JWT with iss == aud and bypass the audience check entirely. Look up the shared secret by the unverified iss, then validate the JWT against a fixed audience (the configured bitbucket.base_url, which Atlassian Connect pins in the descriptor) so the signature check is no longer tautological. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
PR Summary by QodoHarden webhook authentication and block CLI argument injection vectors
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Fix 1 / 5 — Commit 4988386漏洞等级 (Severity): P0 漏洞内容 (Vulnerability): 修改前: webhook_secret = getattr(get_settings().github, 'webhook_secret', None)
if webhook_secret:
body_bytes = await request.body()
signature_header = request.headers.get('x-hub-signature-256', None)
verify_signature(body_bytes, webhook_secret, signature_header)修复方式 (Fix): 当 修改后: webhook_secret = getattr(get_settings().github, 'webhook_secret', None)
if not webhook_secret:
get_logger().error("Rejecting GitHub webhook: GITHUB.WEBHOOK_SECRET is not configured")
raise HTTPException(status_code=403, detail="Webhook secret not configured")
signature_header = request.headers.get('x-hub-signature-256', None)
verify_signature(body_bytes, webhook_secret, signature_header)Reference: wjc2821296948@49883869 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Fix 2 / 5 — Commit af062ba漏洞等级 (Severity): P1 漏洞内容 (Vulnerability): 修改前: comment_body = f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={comment_id} {question}"修复方式 (Fix): 使用 修改后: comment_body = (
f"/ask_line --line_start={shlex.quote(str(start_line))} "
f"--line_end={shlex.quote(str(end_line))} "
f"--side={shlex.quote(str(side))} "
f"--file_name={shlex.quote(str(path))} "
f"--comment_id={shlex.quote(str(comment_id))} "
f"{shlex.quote(question)}"
)Reference: wjc2821296948@af062bad Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Fix 3 / 5 — Commit 03817ad漏洞等级 (Severity): P1 漏洞内容 (Vulnerability): 修改前(节选自 _encoded_args = '...:b3BlbmFpLmtleQ==:QU5BTFlUSUNTX0ZPTERFUg==:...:c2tpcF9rZXlz'修复方式 (Fix): 在黑名单中添加 修改后: _encoded_args = '...:b3BlbmFpLmtleQ==:QU5BTFlUSUNTX0ZPTERFUg==:...:c2tpcF9rZXlz:ZXh0cmFfY29uZmlnX3VybA==:ZGVzY3JpcHRpb25fcGF0aA==:cmV2aWV3X3BhdGg=:aW1wcm92ZV9wYXRo'Reference: wjc2821296948@03817adb Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Code Review by Qodo
1.
|
Fix 4 / 5 — Commit 545dd24漏洞等级 (Severity): P1 漏洞内容 (Vulnerability): Marketplace webhook 处理器( 修改前: @router.post("/api/v1/marketplace_webhooks")
async def handle_marketplace_webhooks(request: Request, response: Response):
body = await get_body(request)
get_logger().info(f'Request body:\n{body}')修复方式 (Fix): 处理器现在直接解析请求体(不进行签名验证,因为通道不同),并仅记录固定标记而非原始正文。 修改后: @router.post("/api/v1/marketplace_webhooks")
async def handle_marketplace_webhooks(request: Request, response: Response):
# Marketplace webhooks do not carry the same x-hub-signature-256 header as
# PR webhooks, so they bypass the signature check in get_body. The handler
# is intentionally a no-op aside from logging: it never publishes comments,
# mutates PR state, or triggers AI calls, so a forged request can only
# poison logs.
try:
body = await request.json()
except Exception as e:
get_logger().error("Error parsing marketplace request body", artifact={'error': e})
raise HTTPException(status_code=400, detail="Error parsing request body") from e
get_logger().info(f'Marketplace request body received')Reference: wjc2821296948@545dd246 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Fix 5 / 5 — Commit 0d990eb漏洞等级 (Severity): P2 漏洞内容 (Vulnerability): 修改前: jwt_parts = input_jwt.split(".")
claim_part = jwt_parts[1]
claim_part += "=" * (-len(claim_part) % 4)
decoded_claims = base64.urlsafe_b64decode(claim_part)
claims = json.loads(decoded_claims)
client_key = claims["iss"]
secrets = json.loads(secret_provider.get_secret(client_key))
shared_secret = secrets["shared_secret"]
jwt.decode(input_jwt, shared_secret, audience=client_key, algorithms=["HS256"])修复方式 (Fix): 仍按未经验证的 修改后: jwt_parts = input_jwt.split(".")
claim_part = jwt_parts[1]
claim_part += "=" * (-len(claim_part) % 4)
decoded_claims = json.loads(base64.urlsafe_b64decode(claim_part))
client_key = decoded_claims.get("iss", "")
if not client_key:
get_logger().error("Bitbucket webhook JWT is missing 'iss' claim")
return
try:
secrets = json.loads(secret_provider.get_secret(client_key))
shared_secret = secrets["shared_secret"]
except Exception as e:
get_logger().error(f"Failed to look up Bitbucket shared secret: {e}")
return
expected_audience = get_settings().bitbucket.base_url
try:
jwt.decode(input_jwt, shared_secret, audience=expected_audience, algorithms=["HS256"])
except jwt.InvalidTokenError as e:
get_logger().error(f"Bitbucket webhook JWT validation failed: {e}")
returnReference: wjc2821296948@0d990eb6 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Qodo's code review pointed out that the previous shlex.quote() attempt was defeated: PRAgent._handle_request() pre-escapes all single quotes in the request string before tokenising with shlex.shlex, so shlex.quote()'s single-quote grouping has no effect and a quoted value with whitespace still splits into multiple argv tokens. The injection vector remained open. Return an argv list from handle_line_comments() instead of a shell-style command string. PRAgent._handle_request() already takes the request as a list/tuple when it isn't a string and bypasses the shlex path entirely, so attacker-controlled whitespace in path / side / comment_id / question can no longer introduce additional CLI arguments. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
Qodo flagged the previous single-line _encoded_args assignment (515 characters) as a Ruff rule violation since the project uses line-length = 120 (AGENTS.md / pyproject.toml). Wrap the literal across multiple lines using implicit string concatenation. The resulting string value is byte-identical to the original (verified by md5 of the stripped line and per-token diff). Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
Follow-up fix — Commit 5091c95 (replaces prior af062ba)漏洞等级 (Severity): P1 漏洞内容 (Vulnerability): Qodo 的代码审查指出,先前 修改前(已被 Qodo 标记为存在缺陷): comment_body = (
f"/ask_line --line_start={shlex.quote(str(start_line))} "
f"--line_end={shlex.quote(str(end_line))} "
...
f"{shlex.quote(question)}"
)修复方式 (Fix): 修改后: cmd = [
"/ask_line",
f"--line_start={start_line}",
f"--line_end={end_line}",
f"--side={side}",
f"--file_name={path}",
f"--comment_id={comment_id}",
]
if question:
cmd.append(question)
return cmdReference: wjc2821296948@5091c956 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Follow-up fix — Commit 47304d1漏洞等级 (Severity): P3 (风格违规,无安全影响) 漏洞内容 (Violation): Qodo 标记 修改前: _encoded_args = 'c2hhcmVkX3NlY3JldA==:...:aW1wcm92ZV9wYXRo' # 515 chars修复方式 (Fix): 使用 Python 隐式字符串拼接把字面量拆成多行,每行 ≤ 90 字符。最终拼接出的字符串值与原值完全一致(通过去掉换行后 md5 校验以及逐 token diff 双重确认)。 修改后: _encoded_args = (
'c2hhcmVkX3NlY3JldA==:dXNlcg==:c3lzdGVt'
':ZW5hYmxlX2NvbW1lbnRfYXBwcm92YWw=:ZW5hYmxlX21hbnVhbF9hcHByb3ZhbA=='
...
':cmV2aWV3X3BhdGg=:aW1wcm92ZV9wYXRo'
)Reference: wjc2821296948@47304d17 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
|
Code review by qodo was updated up to the latest commit 47304d1 |
Qodo pointed out that after handle_line_comments() was changed to return an argv list for /ask line comments, github_action_runner.py still called comment_body.strip().lower() on the result, which raises AttributeError at runtime when an /ask line comment arrives. Only run the string normalisation when the payload is actually a string; pass argv lists through unchanged so PRAgent._handle_request() can take the list branch and skip the shlex parsing path. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
After handle_line_comments() was changed to return an argv list for /ask line comments, the existing unit tests still asserted string semantics (result.startswith, result.endswith) and would have failed on the new return type. Update the assertions to check list membership and index instead, preserving the same semantic coverage. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
Qodo flagged two real bugs in the previous Bitbucket JWT hardening: 1. The base64 + json decode path for the JWT claims was unguarded. A malformed JWT (wrong segment count, invalid base64, invalid JSON, non-object payload) raised an unhandled exception that fell into the outer generic handler, defeating the explicit validation branches and producing noisy error logs. 2. The pinned expected_audience read bitbucket.base_url without checking it was present. The shipped .secrets_template.toml does not define bitbucket.base_url, so a deployment that only follows the template would either AttributeError on every webhook or fail JWT validation for every legitimate Bitbucket event. Guard both code paths: - Verify jwt_parts has at least 3 segments, then wrap the base64/JSON decode in try/except (binascii.Error, ValueError, JSONDecodeError, UnicodeDecodeError). Reject non-dict payloads. - Validate that bitbucket.base_url is reachable and non-empty before using it; otherwise fail closed with a clear log message so the operator knows to set the configuration. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
Qodo's review noted that AGENTS.md says Python code should 'prefer double quotes for strings'. The marketplace webhook handler and the newly rewritten get_body() introduced four lines using single-quoted strings and single-quoted dict keys. Convert those new lines to double quotes. Pre-existing single-quoted strings (e.g. 'x-hub-signature-256', 'webhook_secret') are out of scope per AGENTS.md's guidance to keep fixes mechanical and avoid mixing style churn with logic changes. Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
Follow-up fix — Commit c664716 (resolves Qodo finding #1, real bug)漏洞等级 (Severity): P1 (correctness — AttributeError on every /ask line comment) 漏洞内容 (Vulnerability): Qodo 指出,上一轮把 修改前: if url:
body = comment_body.strip().lower()
...
await PRAgent().handle_request(url, body, ...)修复方式 (Fix): 仅在 修改后: if url:
if isinstance(comment_body, str):
body = comment_body.strip().lower()
else:
body = comment_body
...
await PRAgent().handle_request(url, body, ...)Reference: wjc2821296948@c6647167 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Follow-up fix — Commit e0e0289 (resolves Qodo finding #1 test side)漏洞等级 (Severity): P1 (test correctness) 漏洞内容 (Vulnerability): 修改前: result = github_app.handle_line_comments(body, "/ask Why this change?")
assert result.startswith("/ask_line ")
...
assert result.endswith("Why this change?")修复方式 (Fix): 改成断言列表语义 — 修改后: result = github_app.handle_line_comments(body, "/ask Why this change?")
assert isinstance(result, list)
assert result[0] == "/ask_line"
assert "--line_start=10" in result
...
assert result[-1] == "Why this change?"Reference: wjc2821296948@e0e0289b Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
|
Code review by qodo was updated up to the latest commit 8579fe4 |
Follow-up fix — Commit 3884847 (resolves Qodo findings #3 and #4)漏洞等级 (Severity): P1 (可靠性 — 配置缺失 / 畸形 JWT 导致整个 webhook 处理路径崩溃) 漏洞内容 (Vulnerability): Qodo 在
修改前: jwt_parts = input_jwt.split(".")
claim_part = jwt_parts[1]
claim_part += "=" * (-len(claim_part) % 4)
decoded_claims = json.loads(base64.urlsafe_b64decode(claim_part))
client_key = decoded_claims.get("iss", "")
...
expected_audience = get_settings().bitbucket.base_url
jwt.decode(input_jwt, shared_secret, audience=expected_audience, algorithms=["HS256"])修复方式 (Fix):
修改后: jwt_parts = input_jwt.split(".")
if len(jwt_parts) < 2:
get_logger().error("Bitbucket webhook JWT is malformed (missing segments)")
return
try:
claim_part = jwt_parts[1]
claim_part += "=" * (-len(claim_part) % 4)
decoded_claims = json.loads(base64.urlsafe_b64decode(claim_part))
except (binascii.Error, ValueError, json.JSONDecodeError, UnicodeDecodeError) as e:
get_logger().error(f"Bitbucket webhook JWT claims could not be decoded: {e}")
return
if not isinstance(decoded_claims, dict):
get_logger().error("Bitbucket webhook JWT claims are not a JSON object")
return
client_key = decoded_claims.get("iss", "")
if not client_key or not isinstance(client_key, str):
get_logger().error("Bitbucket webhook JWT is missing 'iss' claim")
return
...
try:
expected_audience = get_settings().bitbucket.base_url
except AttributeError:
get_logger().error("Bitbucket webhook JWT validation skipped: bitbucket.base_url is not configured")
return
if not expected_audience:
get_logger().error("Bitbucket webhook JWT validation skipped: bitbucket.base_url is empty")
return
try:
jwt.decode(input_jwt, shared_secret, audience=expected_audience, algorithms=["HS256"])
except jwt.InvalidTokenError as e:
get_logger().error(f"Bitbucket webhook JWT validation failed: {e}")
returnReference: wjc2821296948@38848476 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Follow-up fix — Commit 8579fe4 (resolves Qodo finding #6, style)漏洞等级 (Severity): P3 (代码风格违规,无安全/正确性影响) 漏洞内容 (Violation): Qodo 指出 AGENTS.md 规定 Python 代码应"prefer double quotes for strings"。本 PR 新引入的 修改前( get_logger().error("Error parsing marketplace request body", artifact={'error': e})
get_logger().info(f'Marketplace request body received')
get_logger().error("Error reading request body", artifact={'error': e})
get_logger().error("Error parsing request body", artifact={'error': e})修复方式 (Fix): 把上述 4 行中的单引号字符串改为双引号,与 AGENTS.md 风格一致。 修改后: get_logger().error("Error parsing marketplace request body", artifact={"error": e})
get_logger().info("Marketplace request body received")
get_logger().error("Error reading request body", artifact={"error": e})
get_logger().error("Error parsing request body", artifact={"error": e})注意: 仓库里其它 pre-existing 的单引号字符串(如 Reference: wjc2821296948@8579fe43 Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
Qodo's review of the latest commit flagged that
handle_marketplace_webhooks() assigned `body = await request.json()`
but never read `body` afterwards, which triggers Ruff/Pyflakes
F841 (unused-local). The project enables Pyflakes ("F") rules in
pyproject.toml and does not ignore F841, so this would fail CI.
The assignment is still load-bearing: the call must execute so a
malformed payload raises and the except branch returns HTTP 400.
Rename the binding to `_` (the conventional "intentionally unused"
name) so the call still runs but F841 no longer fires.
Co-authored-by: cgsdn <chaogeshuodiannao@users.noreply.github.com>
|
Code review by qodo was updated up to the latest commit 34a0d98 |
Follow-up fix — Commit 34a0d98 (resolves Qodo round-3 finding)漏洞等级 (Severity): P3 (lint 违规 — Ruff F841 unused-local,会让 CI 红) 漏洞内容 (Violation): Qodo 在对最新 commit ( 修改前 ( try:
body = await request.json()
except Exception as e:
get_logger().error("Error parsing marketplace request body", artifact={"error": e})
raise HTTPException(status_code=400, detail="Error parsing request body") from e修复方式 (Fix): 把绑定名从 修改后: try:
# Parse the JSON body so a malformed payload returns HTTP 400, but the
# handler is a no-op aside from logging - assign to _ to satisfy Ruff
# F841 (unused-local) without losing the validation side effect.
_ = await request.json()
except Exception as e:
get_logger().error("Error parsing marketplace request body", artifact={"error": e})
raise HTTPException(status_code=400, detail="Error parsing request body") from eReference: wjc2821296948@34a0d98f Co-authored-by: cgsdn chaogeshuodiannao@users.noreply.github.com |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
The security reasoning holds up, and the argv-list refactor is the right call rather than more quoting: PRAgent._handle_request already has the action, *args = request branch, and both call sites are covered. CI is green on 34a0d98f.
Two things before it can land, marked inline.
| # the secret is not configured used to allow any internet caller to | ||
| # trigger expensive AI commands against arbitrary PRs. | ||
| get_logger().error("Rejecting GitHub webhook: GITHUB.WEBHOOK_SECRET is not configured") | ||
| raise HTTPException(status_code=403, detail="Webhook secret not configured") |
There was a problem hiding this comment.
This is a breaking change and worth calling out as one. .secrets_template.toml:78 still describes the secret as "Optional, may be commented out", so every deployment without one starts getting 403s on upgrade.
Worth updating the template and docs/docs/installation/github.md in the same PR, and saying so in the description so it reaches the release notes.
|
Heads-up for the pending rebase: #2736 is about to remove the module-level |
Ok,I will look it. |
Co-authored-by: IsmaelMartinez <ISMAELMARTINEZ@GMAIL.COM>
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks, the runner line is in. #2736 landed on the 25th, so the rebase I flagged is unblocked: both conflicts take your side of the hunk, and the bitbucket one just needs secret_provider swapped for get_fork_safe_secret_provider().
Still open from my last review is the template and docs entry for the breaking change. bitbucket.base_url wants the same, since it is in neither .secrets_template.toml nor configuration.toml and this makes it required.
Say the word if you would rather I pushed the merge to your branch.
Sure, feel free to push the changes directly to my code-review/security-fixes branch. Thanks! |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for the security work, and for letting me push the rebase rather than sending you round again.
Approving. I merged main in as b32fa989, leaving your six commits untouched, and swapped the module-level secret_provider for the accessor #2736 introduced. Then d136c762 adds the documentation that was missing: .secrets_template.toml still called the webhook secret optional, and bitbucket.base_url was documented nowhere despite this making it required as the JWT audience.
All three Qodo findings are closed on this head. Returning argv from handle_line_comments is the better fix than more quoting, since _handle_request still escapes single quotes before shlex sees them.
Two breaking changes for the release notes: deployments without GITHUB.WEBHOOK_SECRET start getting 403s on upgrade, and a Bitbucket app whose bitbucket.base_url does not match the descriptor it was installed with will now drop webhooks silently.
Security review of pr-agent
This PR is the result of a security review of the
pr-agentcodebase. Below are the issues identified, ranked by severity, with the fix implemented in each commit.P0 — Webhook signature verification bypassed when
GITHUB.WEBHOOK_SECRETis unsetFile:
pr_agent/servers/github_app.py(inget_body(), around thewebhook_secretcheck)Issue:
get_body()only validatedx-hub-signature-256whenget_settings().github.webhook_secretwas truthy. A misconfigured deployment — or one that simply forgot to set the secret — silently accepted every webhook as authentic. Any internet caller could then trigger expensive AI commands against arbitrary PRs.Fix:
get_body()now requires a configured secret and rejects the request with HTTP 403 when none is set. Signature verification runs on every request.Commit:
49883869—fix(github_app): require configured webhook secret for GitHub webhooksP1 — CLI argument injection via unescaped webhook fields in
handle_line_commentsFile:
pr_agent/servers/github_app.py(handle_line_comments, line ~370)Issue:
handle_line_commentsinterpolated attacker-controlled webhook fields (path,side,comment_id,question,start_line,end_line) unescaped into a CLI command string. The downstreamshlex.shlexlexer split the result on whitespace, so any field containing a space (e.g.path = "x --local.description_path=/tmp/y") injected an additional CLI argument.validate_user_argsprovided some protection via a blacklist, but several dangerous keys (local.description_path,local.review_path,local.improve_path,extra_config_url) were not on it.Fix: Every value is now passed through
shlex.quote()so the lexer keeps each value as a single argument regardless of its content.Commit:
af062bad—fix(github_app): shlex-quote webhook fields in handle_line_commentsP1 — Forbidden CLI args blacklist missing filesystem write targets
File:
pr_agent/algo/cli_args.py(validate_user_args)Issue:
LocalGitProviderreadslocal.description_path/local.review_path/local.improve_pathdirectly from settings and writes PR-Agent output there. These keys were not on the forbidden CLI args list, so a CLI-arg-injection attacker who bypassed the per-field quoting could still point them at arbitrary filesystem locations (cron files, SSH keys, config files).Fix: Added
description_path,review_path,improve_path, andextra_config_urlto the forbidden list. The blacklist uses substring matching, so the bare keys also block the section-prefixed variants.Commit:
03817adb—fix(cli_args): block description_path / review_path / improve_path / extra_config_urlP1 — Marketplace webhook echoes raw body to logs and no longer parses cleanly
File:
pr_agent/servers/github_app.py(handle_marketplace_webhooks)Issue: The marketplace webhook handler used the shared
get_body()(now requiring signature verification) but marketplace webhooks do not carry the samex-hub-signature-256header. The endpoint also logged the entire parsed body, allowing a forged request to inject arbitrary content into CI logs.Fix: The marketplace handler now parses the body inline (without signature verification, since the channel differs) and logs only a fixed marker instead of the raw body.
Commit:
545dd246—fix(github_app): avoid logging raw marketplace webhook bodyP2 — Bitbucket JWT validation uses unverified
issasaudienceFile:
pr_agent/servers/bitbucket_app.py(webhook handler around the JWT decode)Issue: The handler decoded the
issclaim from the JWT body before signature verification and then passed that same unverifiedissas theaudienceargument tojwt.decode(). Because the audience check isaudience == token["aud"], an attacker could mint a JWT withiss == audand satisfy the audience check trivially. The only thing standing between them and the API was the HMAC against the secret looked up by their own (unverified)issclaim.Fix: Look up the shared secret by the unverified
issas before, but pin the audience parameter to the configuredbitbucket.base_url(which Atlassian Connect pins in the descriptor) so the signature check is no longer tautological. Add explicit handling for missingiss, missing secrets, and invalid tokens.Commit:
0d990eb6—fix(bitbucket_app): pin JWT audience to configured base_urlTest plan
Each fix is a minimal, behavior-preserving change:
GITHUB.WEBHOOK_SECRETand confirming the endpoint returns 403.path/comment_idand confirming the values are quoted in the resulting CLI command.CliArgs.validate_user_argstests.audis not the configuredbase_url.🤖 Generated with Claude Code