Skip to content

fix: Potential fix for code scanning alert no. 1: Construction of a cookie using user-supplied input#116

Draft
teolemon wants to merge 1 commit intomainfrom
alert-autofix-1
Draft

fix: Potential fix for code scanning alert no. 1: Construction of a cookie using user-supplied input#116
teolemon wants to merge 1 commit intomainfrom
alert-autofix-1

Conversation

@teolemon
Copy link
Copy Markdown
Member

Potential fix for https://github.com/openfoodfacts/nutripatrol/security/code-scanning/1

To fix the problem, we should ensure that the value used for the session cookie is validated and sanitized before being set. The best approach is to restrict the allowed characters in the session value to a safe subset (e.g., alphanumeric and a few safe symbols), and reject or sanitize any input that does not conform. This can be done by adding a regex validation to the SessionBody Pydantic model, ensuring that only safe session values are accepted. This change should be made in the definition of SessionBody in app/api.py. No changes to imports are needed, as Pydantic is already imported.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… using user-supplied input

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@teolemon teolemon changed the title Potential fix for code scanning alert no. 1: Construction of a cookie using user-supplied input fix: Potential fix for code scanning alert no. 1: Construction of a cookie using user-supplied input Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant