[BUG]: Receipt ledger trusts comments from any installed bot, bypassing write permission checks

Open
#92 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

@AyushSrivastava1818 is already working on this.

Since Nov 14, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
github-actions, typescript

Research direction

Start in src/adapters/github/receipts.ts with isTrustedReceiptAuthor() and vouched(), then follow PullRequestReceiptLedger.lookup() to see where the trust result is used. Check how hasWriteAccess() is called for human commenters, since the fix should route non-workflow bots through the same check. Done means a bot comment without write permission is not trusted, and a test covers that case; the expected workflow identity needs a maintainer decision first.

Written by the indexing model from the issue text.

Description

bug
Bug Description

In src/adapters/github/receipts.ts, isTrustedReceiptAuthor() and vouched() treat any commenter with comment.user?.type === "Bot" as an authorized receipt author without verifying repository write permissions:

export function isTrustedReceiptAuthor(comment: CommentLike): boolean {
  if ((comment.user?.type ?? "") === "Bot") return true;
  return TRUSTED_ASSOCIATIONS.has((comment.author_association ?? "").toUpperCase());
}

GitPay's documented security model (lines 125–134) states:
"Only receipts written by the automation or by someone who can already spend the project's money are believed. A forged receipt withholds a payment rather than causing one, so this is griefing protection rather than theft protection — but a contributor should not be able to block someone else's payout with a comment."

While human commenters are validated against repository write permissions via hasWriteAccess(), all bot comments bypass this check completely.

Any GitHub App installed on the repository or organization with issue/PR commenting permissions (such as preview bots, triage bots, or CI reporters with read/comment permissions but without repository push permissions) is unconditionally trusted. If an installed bot echoes unvetted PR metadata, logs, or commit messages containing a receipt marker (<!-- xops-receipt:v1 key=... status=settled -->), GitPay treats the payout as AUTH_ALREADY_USED and suppresses contributor payout.

Steps to Reproduce
  1. In a pull request with an eligible payout, have an installed GitHub App with read/comment permissions post a comment containing:
    <!-- xops-receipt:v1 key=<idempotency_key> status=settled -->
  2. Run the GitPay settlement action.
  3. Observe that PullRequestReceiptLedger.lookup() finds the comment, treats it as a vouched receipt, and aborts the payout as already settled without verifying write permissions.
Logs and Screenshots

Reproduction verifying bot bypass:

const untrustedBotComment = {
  body: '<!-- xops-receipt:v1 key=0x1234567890abcdef status=settled -->',
  user: { login: 'triage-preview-bot[bot]', type: 'Bot' },
  author_association: 'NONE'
};

const trusted = isTrustedReceiptAuthor(untrustedBotComment);
// Returns true — trusts bot with NONE association without calling hasWriteAccess()

Suggested fix in src/adapters/github/receipts.ts:
Scope automatic receipt trust specifically to GitPay's own workflow identity (e.g. github-actions[bot] or the configured actor) rather than all installed bots. Treat other bots like human commenters by validating them with hasWriteAccess():

export function isTrustedReceiptAuthor(comment: CommentLike, expectedBotLogin?: string): boolean {
  const login = comment.user?.login?.toLowerCase();
  const trustedBot = (expectedBotLogin || "github-actions[bot]").toLowerCase();
  if (comment.user?.type === "Bot" && login === trustedBot) {
    return true;
  }
  return TRUSTED_ASSOCIATIONS.has((comment.author_association ?? "").toUpperCase());
}
Environment Details
  • Component: src/adapters/github/receipts.ts
  • Runtime: Node.js 20+ / GitHub Actions
  • OS: Ubuntu runner / Linux
  • Branch: main
Impact

Medium - Feature works but has issues

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Dominant language
TypeScript
Stars
5
Forks
4
Avg merge
2d 12h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StabilityNexus/GitPay

All issues in StabilityNexus/GitPay

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.