-
Notifications
You must be signed in to change notification settings - Fork 244
Content Size & Type Security Limits for Resources & Prompts #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Nayana-R-Gowda
wants to merge
11
commits into
IBM:main
Choose a base branch
from
Nayana-R-Gowda:538content-size
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Signed-off-by: NAYANAR <[email protected]>
Signed-off-by: <Nayana R Gowda> <[email protected]>
Signed-off-by: NAYANAR <[email protected]>
8 tasks
Signed-off-by: NAYANAR <[email protected]>
Signed-off-by: NAYANAR <[email protected]>
5319c94
to
35bad14
Compare
Signed-off-by: NAYANAR <[email protected]>
4f6646f
to
0567d0f
Compare
Signed-off-by: NAYANAR <[email protected]>
Signed-off-by: NAYANAR <[email protected]>
madhav165
reviewed
Aug 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why is rate limiting code in middleware and content validation in services? Check if there is a reason for the suggestion and if it makes it easier to use.
- Don't remove the top content from files - e.g. prompt_service
- In admin_reset_rate_limiter, why is rate limit not being reset for a specific user?
- Fix duplicate definitions for content_max_resource_size in config.py
- Why is
validation_exception_handler
removed in main andcontent_validation_exception_handler
added? Updatevalidation_exception_handler
if possible - Keep .env.example values consistent with what is there in config.py.
- Test cases are fine
Overall, might be better to do a new PR from current main to avoid merge conflicts, address the issues mentioned above.
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
What problem does this PR fix and why?
It prevents security risks like XSS, malicious payloads, and DoS attacks from unvalidated resource/prompt content. Without validation, users could upload unsafe content or overwhelm the system with large inputs. This ensures only safe, properly sized, and valid text content is processed.
💡 Fix Description
How did you solve it? Key design points.
I added configurable content size/type limits, UTF-8 and pattern validation, and prompt syntax checks. Built a ContentSecurityService for centralized checks, plus a rate limiter to block abuse. API services now enforce validation on create/update with monitoring for violations.
🧪 Verification
make lint
make test
📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit
)