Opened 4 weeks ago

Last modified 4 weeks ago

#37326 assigned Cleanup/optimization

Improved docs for Signer to encourage more secure patterns.

Reported by: Tim Schilling Owned by: Md. Saikat Islam
Component: Documentation Version: dev
Severity: Normal Keywords: Security, Signing, Salt
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

​This is based on spookeylukey's PR from a few years ago. Creating a ticket to track any discussion.

After seeing a colleague use Signer/TimestampSigner without the salt argument passed, I looked at the docs and found that they do not really encourage its use. This is unfortunate, because it really is required to avoid hacks once you have more than one use of it in your application. The best way to ensure correct usage is to always add the argument.

While I was there, I took the opportunity to explain and encourage better patterns, and updated the get_signed_cookie and set_signed_cookie docs accordingly.

Passing salt to set_signed_cookie is not quite as necessary, because it already uses the key value as a salt, but I think it is still helpful. In a large project, it's possible that the same key could be validly used for set_signed_cookie(key) but with different purposes - for example they might use a different path argument, so the cookies wouldn't clash at the browser level, and therefore they wouldn't notice the clash.

If accepted, SpookeyLukey's changes should be rebased on the latest version of main. I left a review on the PR for some language improvements. Here is a patch file that should handle the rebasing bit.

Attachments (1)

0001-Improved-docs-for-Signer-to-encourage-more-secure-pa.patch​ (9.0 KB ) - added by Tim Schilling 4 weeks ago.

Download all attachments as: .zip

Change History (2)

comment:1 by Md. Saikat Islam, 4 weeks ago

Owner: set to Md. Saikat Islam
Status: new → assigned
Triage Stage: Unreviewed → Accepted

I will follow your suggestions on that PR.

Note: See TracTickets for help on using tickets.
Back to Top