Fix Gunicorn thread-pool worker mutation bypass in config scanner - #253
Conversation
Extend the gunicorn.conf.py AST scanner to treat ThreadPool.map and ThreadPoolExecutor submit().result() callbacks like threading.Thread.start() when they mutate workers during config import. Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_e17554ff-aa6a-4359-b56b-5e3590251ff3) |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a75b47a6ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1fc46923-d1a9-4086-8719-92e87dcbd0d9) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_ce6dcf35-e25f-497b-8e71-fb989304f5b0) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_6a862271-3aa6-40b3-8083-b4ccea0fb8d2) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_24fd24ad-8fd3-4233-8a76-5cc8e152773b) |
|



Security fix (High)
Issue: #252
Location:
config.pyImpact: A
gunicorn.conf.pythat leavesworkers = 1for static analysis but mutatesworkersat import time viaThreadPoolExecutor.submit(...).result()ormultiprocessing.pool.ThreadPool.map(...)could start multiple Gunicorn workers while the panel keepsmemory://rate limiting and per-worker sessions, multiplying login brute-force throughput and weakening logout/session guarantees.Remediation: Treat import-time
ThreadPool.mapandsubmit(...).result()callbacks that mutateworkerslike existingthreading.Thread.start()detection in the Gunicorn config AST scanner. Regression cases added intests/test_gunicorn_indirect_workers_bypass.py.Closes #252.
Note
High Risk
Changes security-sensitive static analysis of Gunicorn worker counts; incorrect detection could leave session/rate-limit assumptions wrong when extra workers run.
Overview
Closes a static-analysis bypass where
gunicorn.conf.pycould mutateworkersat import time throughThreadPool.maporThreadPoolExecutor.submitwithout being flagged as dynamic.The Gunicorn config AST pipeline now tracks
ThreadPool/ThreadPoolExecutorimports (including aliases and module-qualified calls), binds pool instances from assignments andwithblocks, and treatsmap,submit, and mutatinginitializercallbacks like existing eager consumers of risky lazy iterators._call_consumes_mutating_lazy_iteratoris refactored into smaller helpers and extended with these thread-pool cases; new binding slots are wired intooperator_bindingsbefore import-time mutation checks.Regression coverage adds direct pool examples to the dynamic bypass suite plus a dedicated parametrized test for aliases, saved receivers, named callbacks, nested risky iterables, initializers, and a negative case for a custom
submitstub.Reviewed by Cursor Bugbot for commit a6fb45c. Bugbot is set up for automated code reviews on this repo. Configure here.