Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

[DO NOT MERGE] Rules for generating a cryptographic footprint#1

Draft
urnfdog wants to merge 28 commits intomainfrom
klai/cryptographic-footprint
Draft

[DO NOT MERGE] Rules for generating a cryptographic footprint#1
urnfdog wants to merge 28 commits intomainfrom
klai/cryptographic-footprint

Conversation

@urnfdog
Copy link
Copy Markdown
Collaborator

@urnfdog urnfdog commented Mar 22, 2022

WIP

These rules (attempts to) generate a listing of all cryptographic algorithms and ciphers used in a program. This can be used as a general summary or tweaked to become compliance rules for specific sets of issues.

Tests can be run with the following:

  • In go-queries/CryptographicFootprint/tests
  • go mod vendor
  • Back to go-queries
  • codeql test run CryptographicFootprint/tests/ --search-path=.

Currently, this provides a set of rules for Go as CWE-327 is still experimental.

Python already has a check for CWE-327 (BrokenCryptoAlgorithm.ql) that is likely to get tweaked and then pulled in, and one that is inclusive of ALL cryptographic operations detected, not just weak ones. Update: This is now in progress, and from those rules we now have .* regex matching. However, I'm not likely to extend that too far due to false positives.

TODOs

  • Integrate tests into Github actions CI/CD
  • Get in contact with the teams working on weak crypto rules once we're a little more experienced and see if there's some sort of collaboration possible

urnfdog added 15 commits March 14, 2022 13:24
- WIP rules for checking presence of cryptographic ciphers and functions
- Note that testing is iffy - next commit will refactor testing just didn't want to clog up this commit with that.
- Tests apparently require the corresponding queries to be in a parallel query directory structure
- Run with "codeql test run tests/ --search-path=queries/" at the CryptographicFootprint directory
- Removed unnecessary imports on previous test and misc cleanup
- Continuation of a03c976 applied to the rest of the queries
- Also added check for single invocation without comment
- Also update disallowed password tests to correct for indentation error
- Goodbye jank test runs, hello codeql native tests
@urnfdog urnfdog added the wip label Mar 22, 2022
urnfdog added 11 commits March 22, 2022 15:32
- No longer limited to existing CWE-327 data flow tracking, this now works on functions as they're being broadly called
- This introduces regex checks for the first time, adapted from CWE-327 implementation
- Reusing that requires overwriting their type TCryptographicAlgorithm but this may be a source of refactor later to combine, since CryptographicOperation is not necessary
- Minor cleanup and tweaks for hashing rules
- This would keep default query suites from seeing these rules as part of the codeql/go-queries
- Test are now run at the go-queries level with the following command:
- codeql test run CryptographicFootprint/tests/ --search-path=.
- Tests are now run with the following from python-queries:
- codeql test run CryptographicFootprint/tests/ --search-path=.
- Introduces regex matching type to CryptoLibraries
- Also updated tests for the new Detected X from Y language
@urnfdog urnfdog marked this pull request as draft October 6, 2023 21:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant