Skip to content

test(audit): cover audit log tamper resistance, actor binding, and rollback safety (#2062) - #2206

Open
huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2062-audit-log-tamper-resistance
Open

huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2062-audit-log-tamper-resistance

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Adds deterministic unit test coverage in backend/src/services/__tests__/auditLogService.tamperResistance.test.ts for audit log tamper resistance, actor identity binding, and rollback safety across backend/src/services/auditLogService.ts and backend/src/middleware/auditLog.ts:

  • Immutable event fields & read-only service surface: Verifies auditLogService exports strictly read and cursor functions (decodeCursor, encodeCursor, getAuditLogs) with no update/delete mutators, and rejects tampered or malformed keyset cursors without SQL injection.
  • Actor identity binding & filter parameterization: Verifies getAuditLogs parameterizes actor, action, from, to, and keyset cursor predicates in both page and COUNT(*) queries, and verifies auditLog middleware binds actor from authenticated req.user.publicKey (ignoring spoofed req.body.actor) while snapshotting and redacting sensitive fields (secret, apiKey, signedTxXdr) at request entry.
  • Transaction rollback & DB failure handling: Verifies transactional audit_logs inserts on a PoolClient roll back atomically when a downstream mutation fails, and verifies DB rejection errors are logged via logger.error('Audit logging failure', ...) without unhandled rejections.

Closes #2062

Verification

  • node --experimental-vm-modules node_modules/jest/bin/jest.js --forceExit src/services/__tests__/auditLogService.tamperResistance.test.ts src/services/__tests__/auditLogService.pagination.test.ts: 20 passed, 0 failed.

Payout Wallets

  • Stellar (XLM / USDC): GBYWLISGOUWQ43VQEGXX6KRGDZ3CKAFFK3JXVLXKDO5TIFJUJ3OHJYOZ
  • EVM / Base USDC: 0x380C97bcbcAEf29DAc2d0ba7E180F1b4A7F38fdd
  • Solana (USDC / SOL): AyXYaA9Nf4z5fpLKY6DmubWe6D2qveMd79w8pEDNHcDw

@github-actions github-actions Bot added the security:malware-suspected Automated malware indicator found in a pull request label Oct 27, 2026
@github-actions

Copy link
Copy Markdown

Malware detection scan flagged this pull request

The scan found 1 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.

  • backend/src/services/__tests__/auditLogService.tamperResistance.test.ts — hidden-appended-config-payload (high)

This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security:malware-suspected Automated malware indicator found in a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test] Cover audit log tamper resistance

1 participant