You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tooling.apache.org by "andrewmusselman (via GitHub)" <gi...@apache.org> on 2026/02/25 19:10:00 UTC

[I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

andrewmusselman opened a new issue, #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789

   **ASVS:** 3.5.1, 3.5.3 · **CWE:** CWE-352 · **Files:** Multiple in `atr/post/*.py`
   
   ### Description
   
   Several POST endpoints use the `@post.empty()` decorator, meaning they expect no form body. While the global `quart_wtf.CSRFProtect(app)` middleware should cover all POST requests, this should be explicitly verified for empty-body requests. If the middleware relies on reading a CSRF token from the request body, these endpoints may be unprotected.
   
   **Affected endpoints:**
   - `POST /draft/fresh/<project>/<version>`
   - `POST /draft/hashgen/<project>/<version>/<path>`
   - `POST /draft/recheck/<project>/<version>`
   - `POST /draft/sbomgen/<project>/<version>/<path>`
   - `POST /keys/import/<project>/<version>`
   - `POST /manual/start/<project>/<version>/<revision>`
   - `POST /tokens/jwt`
   
   ### Recommended action
   
   1. Verify that `CSRFProtect` validates the `X-CSRFToken` header (set by JavaScript) for these endpoints.
   2. If not covered, add explicit Sec-Fetch-Site validation or require a custom header.
   3. Consider using `@post.form(EmptyCSRFForm)` instead of `@post.empty()` for documentation clarity.
   4. See sub-issues for specifics


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789#issuecomment-4039885546

   Yeah. The CSRF hook is applied to all routes with the exception of the deliberate exemptions, and it runs before it even gets to our code. The audit tool was only concerned whether the "middleware relies on reading a CSRF token from the request body", so you can see why it was confused: we call the form `Empty` but that actually means `CSRFFieldOnly` in practice. The CSRF field is always applied by `form.py`, including to `Empty`. If it were not applied, the CSRF hook would reject such submissions anyway.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "alitheg (via GitHub)" <gi...@apache.org>.
alitheg commented on issue #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789#issuecomment-4022858812

   I've just tested this for a form.empty (POST `/tokens/jwt`) and it works, it grabs the token from the form and validates it so I think we can close this - do you agree @sbp?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789#issuecomment-4040777430

   Added audit guidance in b69e8055d19b08a7c0fb8dee81c6e2382e75229a.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "alitheg (via GitHub)" <gi...@apache.org>.
alitheg commented on issue #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789#issuecomment-4039918621

   Ah that's the other thing I was going to suggest @sbp - for readability we could change `form.Empty` to `form.CSRFOnly`? I did spend a little time trying to work out what the point in the empty form was so it might help humans too!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp closed issue #789: Verify CSRF coverage for `@post.empty()` decorated endpoints
URL: https://github.com/apache/tooling-trusted-releases/issues/789


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org


Re: [I] Verify CSRF coverage for `@post.empty()` decorated endpoints (tooling-trusted-releases)

Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #789:
URL: https://github.com/apache/tooling-trusted-releases/issues/789#issuecomment-4040748271

   Maybe, but it's empty from the app perspective: the CSRF ought to be pure middleware injection, it's just that we took that over. We would need empty forms still even if CSRF didn't exist, to make it use POST. Finally, `@form.empty()` is cleaner than `@form.csrf_only()`. But indeed `CSRFOnly` is more explicit, and I don't really mind either way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org