Skip to content

Potential fix for code scanning alert no. 14: Failure to use secure cookies #906

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SaboniAmine
Copy link
Member

Potential fix for https://github.com/mlco2/codecarbon/security/code-scanning/14

To address the issue, we should ensure that the cookie is always created with secure attributes:

  1. Set the secure attribute to True to ensure the cookie is only transmitted over HTTPS.
  2. Add the samesite attribute with a value of 'Lax' to protect against CSRF attacks while allowing some cross-origin requests.
  3. Verify that the httponly attribute remains set to True to prevent JavaScript access to the cookie.

These changes should be applied to the response.set_cookie call in the provided code.


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

…ookies

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@SaboniAmine SaboniAmine requested a review from prmths128 July 13, 2025 14:47
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.

1 participant