Skip to content

fix(security): reject imported and setattr Gunicorn workers with memory:// - #161

Merged
AlexanderWagnerDev merged 3 commits into
mainfrom
fix/gunicorn-import-workers-bypass
Sep 3, 2026
Merged

fix(security): reject imported and setattr Gunicorn workers with memory://#161
AlexanderWagnerDev merged 3 commits into
mainfrom
fix/gunicorn-import-workers-bypass

Conversation

@cursor

@cursor cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Security fix

Severity: Medium

Location: config.py

Issue: #160

Impact

Gunicorn configs that bind workers via from module import workers, star imports, or object.__setattr__(..., "workers", N) were treated as single-worker deployments. With RATELIMIT_STORAGE_URI=memory://, startup succeeded while Gunicorn still forked multiple workers, multiplying login rate-limit buckets and breaking cross-worker session revocation.

Remediation

  • Flag ImportFrom statements that import workers or * as dynamic.
  • Treat object.__setattr__ calls binding workers like existing setattr detection.
  • Add regression tests for imported/setattr/star-import config patterns.

Closes #160

Open in Web View Automation 

Note

Medium Risk
Changes startup security validation for multi-worker + in-memory rate limits; behavior is intentionally stricter for some Gunicorn config patterns.

Overview
Tightens Gunicorn config AST scanning so workers set via imports, star imports, or object.__setattr__ is treated as dynamic, matching existing setattr handling. That forces a shared rate-limit backend (or blocks startup) when RATELIMIT_STORAGE_URI=memory://, instead of assuming a single worker while Gunicorn forks many.

New helpers _call_sets_workers_attribute and _import_from_binds_workers plug into the workers walk and dynamic-mutation checks. Imports that bind workers or * are flagged; from module import workers as other_name is not flagged.

Regression coverage adds startup rejection tests for imported workers and object.__setattr__, extends the security parametrized cases, and asserts aliased imports stay non-dynamic.

Reviewed by Cursor Bugbot for commit 75d6739. Bugbot is set up for automated code reviews on this repo. Configure here.

…ry://

The startup AST scan treated gunicorn configs that bind workers via
import/from-star or object.__setattr__ as single-worker deployments,
allowing memory:// rate limiting and per-process sessions while Gunicorn
actually forks multiple workers.

Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
@AlexanderWagnerDev

Copy link
Copy Markdown
Contributor

@codex review

@AlexanderWagnerDev
AlexanderWagnerDev marked this pull request as ready for review September 3, 2026 12:20
@cursor

cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot 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_ceb94b1b-4ba2-45f4-a60f-ae9256a0ac1c)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 771828b09a

ℹ️ 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".

Comment thread config.py Outdated
@cursor

cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot 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_1b4c92c3-5d9c-4ada-9e23-2e07e4574cbb)

@cursor

cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot 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_b4950c2c-0c05-45a3-a131-1b27ce43fd27)

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

@AlexanderWagnerDev
AlexanderWagnerDev merged commit fda3e27 into main Sep 3, 2026
12 checks passed
@AlexanderWagnerDev
AlexanderWagnerDev deleted the fix/gunicorn-import-workers-bypass branch September 3, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gunicorn config imported or setattr-bound workers bypass startup rate-limit and session guards

2 participants