Fix(finstripe): validate vendor_account against registered bank account before transfer#458
Open
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Open
Fix(finstripe): validate vendor_account against registered bank account before transfer#458Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Conversation
…nt before transfer Root cause: vendor_account was a free-form caller-supplied string never compared to vendor.bank_account_number, allowing funds to be routed to arbitrary accounts. Solution: Fetch vendor record inside db_session and assert vendor_account equality before create_transaction is called. Return error dict on mismatch or missing vendor; no transaction is written. Impact: Write path is guarded pre-commit. Valid callers unaffected. No schema, dependency, or API contract changes. Signed-off-by: JEAN REGIS <240509606@firat.edu.tr>
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.
Summary
Fixes #327
Resolves a critical payment redirection vulnerability in
create_transferwherevendor_accountwas never validated against the vendor's registered bank account,allowing funds to be routed to any attacker-controlled destination.
Problem
create_transferacceptedvendor_accountas a free-form caller-supplied stringand passed it directly into logging and the response payload never comparing it
to the vendor's actual
bank_account_numberstored in the database.This means any caller (including a prompt-injected MCP agent) could supply an
arbitrary account string, and the transfer would be created and marked
completedwithout any ownership check.
Vulnerable path:
Reproduced via:
Root Cause
The
create_transfertool opened adb_session, fetched nothing about the vendor,and called
repo.create_transaction()unconditionally. Thevendor_idparameterwas used only as a foreign key on the transaction record never to retrieve the
vendor and cross-check ownership of the supplied account number.
There was no validation layer between the caller-controlled
vendor_accountargument and the committed transaction.
Solution
Inside the existing
db_sessionblock, beforecreate_transactionis called,the fix:
repo.get_vendor_by_id(vendor_id)vendor_accountstrictly againstvendor.bank_account_numbercreate_transactionis never reachedThe transaction write is now unreachable unless the supplied account exactly
matches the registered one. No fuzzy matching, no normalization, strict equality
against the canonical stored value.
Security Impact
vendor_accountvendor_idWhat Was Not Changed
Testing
Acceptance test (must pass):
Full suite regression:
Prerequisite for Merge
This patch calls
repo.get_vendor_by_id(vendor_id)onPaymentTransactionRepository. Confirm this method exists and returns an objectwith a
.bank_account_numberattribute before merging. If it does not exist, acompanion repository method must be added first.
Tasks
vendor_accountparameter increate_transferrepo.get_vendor_by_id(vendor_id)call inside existingdb_sessionblockvendor_account != vendor.bank_account_numbertest_mcp_create_011_arbitrary_vendor_account_acceptednow passes