Fix(finmail): resolve unbounded sender_name storage with length guard#438
Open
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Open
Fix(finmail): resolve unbounded sender_name storage with length guard#438Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Conversation
Root cause: effective_sender was passed to route_and_deliver without length validation, allowing 10,000-char strings to persist in DB and appear in every list_inbox summary response. Solution: Add MAX_SENDER_NAME = 100 constant and an early-return guard after effective_sender resolution, before any DB interaction. Impact: Deterministic rejection of oversized names; zero effect on valid inputs; no changes to route_and_deliver or DB schema. 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 #348
Rejects
sender_namevalues exceeding 100 characters insend_emailbeforethey reach the database, preventing oversized strings from poisoning LLM context
on every
list_inboxcall.Problem
send_emailaccepted arbitrarily longsender_namevalues with no lengthvalidation. A caller could pass a 10,000-character string which was:
emailstable viaroute_and_deliverlist_inboxsummary response viato_summary_dict()Reproduction:
Root Cause
effective_senderwas forwarded directly toroute_and_deliverwithout anylength check:
This allowed unbounded strings to persist in the DB and surface in all
subsequent inbox listing responses.
Solution
Added a module-level constant and an early-return guard immediately after
effective_senderis resolved — before any DB interaction occurs:No other code paths, function signatures, or DB schema are affected.
Files Changed
finbot/mcp/servers/finmail/server.pyMAX_SENDER_NAME = 100constant + 2-line length guard insend_emailEdge Cases Covered
sender_name=""or omitteddefault_sender("OWASP FinBot") passes ✅sender_name="A" * 100sender_name="A" * 101sender_name="A" * 10_000len()counts code points safe for a name field ✅Impact
route_and_deliver, DB schema, or any other toolTesting
Before fix:
After fix:
Checklist