-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: cookie and biscotti crypto query sinks #20426
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds cryptographic key modeling for the cookie and biscotti crates to detect when hard-coded cryptographic values are passed as keys. The changes include models for key creation functions and test updates to verify the new detection capabilities.
- Added sink models for
cookie::Key::fromandbiscotti::Key::fromto detect hard-coded cryptographic keys - Consolidated the scattered manual models for
<core::convert::From>::frominto a single generic model - Added a model for
alloc::vec::from_elemto track element propagation
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/query-tests/security/CWE-798/test_cookie.rs | New test file demonstrating hard-coded cryptographic key usage in cookie and biscotti libraries |
| rust/ql/test/query-tests/security/CWE-798/options.yml | Added cookie and biscotti crate dependencies for testing |
| rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected | Updated test expectations with new detections for cookie/biscotti hard-coded keys |
| rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected | Updated expectations reflecting the consolidated From model changes |
| rust/ql/test/library-tests/dataflow/strings/inline-taint-flow.expected | Updated expectations with new generic From model |
| rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml | Added generic <_ as core::convert::From>::from model |
| rust/ql/lib/codeql/rust/frameworks/stdlib/lang-alloc.model.yml | Added alloc::vec::from_elem model and removed specific String From model |
| rust/ql/lib/codeql/rust/frameworks/stdlib/fs.model.yml | Removed PathBuf From model in favor of generic one |
| rust/ql/lib/codeql/rust/frameworks/cookie.model.yml | New model file defining cookie key sink |
| rust/ql/lib/codeql/rust/frameworks/biscotti.model.yml | New model file defining biscotti key sink |
| rust/ql/lib/change-notes/2025-09-12-cookie.md | Added change note for the new cryptography models |
|
DCA LGTM (small slowdown, believed to be wobble). |
paldepind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great to have one single from model :)
|
Thanks for reviewing. |
| - ["<alloc::string::String as core::convert::Into>::into", "Argument[self].Element", "ReturnValue.Element", "taint", "manual"] | ||
| - ["<alloc::string::String as core::convert::Into>::into", "Argument[self].Reference.Element", "ReturnValue.Element", "taint", "manual"] | ||
| # From | ||
| - ["<_ as core::convert::From>::from", "Argument[0]", "ReturnValue", "value", "manual"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected that this should be a taint model and not a value model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - here: #20529
While writing the insecure cookie query (WIP), I've been using the
cookieandbiscotticrates. I noticed they both have the capability to take encryption keys and this can be modelled.In addition to modelling those I've added a model for
alloc::vec::from_elemand cleaned up the scattered manual models for<core::convert::From>::from.