Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
3f44a23
Adjust alert location UntrustedCheckoutCritical
knewbury01 May 5, 2026
b6155ff
Swift: Test spacing.
geoffw0 May 1, 2026
dc863c3
Swift: Add test cases for an alternative pattern of calls to Insecure…
geoffw0 May 1, 2026
d95001f
Rust: Additional test cases for sensitive data heuristics.
geoffw0 May 6, 2026
07d4df1
Shared: Add 'card.?no' sensitive data heuristic.
geoffw0 May 6, 2026
cb84e63
Shared: Fix for 'wildcard'.
geoffw0 May 6, 2026
b60ce3c
Shared: Fix for 'profile'.
geoffw0 May 6, 2026
213ab90
Shared: Fix for 'api_tok'.
geoffw0 May 6, 2026
6e2fb6f
Shared: Fix for 'coauthor'.
geoffw0 May 6, 2026
5ed78d1
Shared: Fix and simplify the exclusion for 'encrypted' values.
geoffw0 May 6, 2026
f2f4f4c
Shared: Add 'security_code' sensitive data heuristic.
geoffw0 May 6, 2026
809da0f
Shared: Autoformat.
geoffw0 May 7, 2026
7c72898
Merge remote-tracking branch 'upstream/main' into extsensitive
geoffw0 May 7, 2026
0f8b0a7
Swift: Accept test changes (improvement).
geoffw0 May 7, 2026
ea711b0
Javascript: Accept test changes (regression).
geoffw0 May 7, 2026
1c704a0
Python: Accept test changes (improvement).
geoffw0 May 7, 2026
df37b50
Shared: Small adjustment to the encrypt not-sensitive regex.
geoffw0 May 7, 2026
3694631
Shared: Autoformat.
geoffw0 May 7, 2026
af0124f
Merge branch 'main' into extsensitive
geoffw0 May 11, 2026
51dae16
Merge branch 'main' into extsensitive
geoffw0 May 12, 2026
ef1bde7
Widen pinned SHA regex to support SHA-256 (64-char hex) and add tests
Copilot May 12, 2026
48b1dad
Add change note for SHA-256 pinned actions support
Copilot May 12, 2026
0620d34
Update Bash alphaNumericRegex to match grouped quantified forms
Copilot May 12, 2026
562f415
Tidy Bash alphaNumericRegex comment spacing
Copilot May 12, 2026
2067113
Update expected test output
owen-mc May 12, 2026
f582680
Add change note for alphanumeric regex change
owen-mc May 12, 2026
ea29986
Fix non-US english by using "parentheses" instead of "brackets"
owen-mc May 12, 2026
ac7eb01
C#: Add Increment/Decrement instance operator test example and update…
michaelnebel May 4, 2026
3c9d898
C#: Adjust the extractor to correctly handle names for user defined i…
michaelnebel May 5, 2026
4ae4d7d
C#: Update condition for UnaryOperators to also handle user-defined i…
michaelnebel May 5, 2026
1c50c0c
C#: Update PrintAst expected output.
michaelnebel May 5, 2026
25274a1
C#: Add an increment/decrement operator test case.
michaelnebel May 5, 2026
9a80508
C#: Improve the GetCallType method to also take extension operators i…
michaelnebel May 6, 2026
23328e9
C#: Add extension increment/decrement examples.
michaelnebel May 11, 2026
27e6b5c
C#: Introduce a class for instance mutator operator calls.
michaelnebel May 11, 2026
0c3ab80
C#: Update the dispatch logic to account for all instance operator ca…
michaelnebel May 11, 2026
4bd9005
C#: Add data flow testcases for mutation operators.
michaelnebel May 11, 2026
5ed3014
C#: Add change-note.
michaelnebel May 12, 2026
fa2d633
C#: Address co-pilot review comments.
michaelnebel May 13, 2026
d16bc36
Use relative paths in tree-sitter extractor diagnostics
redsun82 May 13, 2026
57ac019
Fix formatting
redsun82 May 13, 2026
1e6570e
C#: Update paket to 10.3.1.
michaelnebel May 13, 2026
c3cf7c2
Use absolute path fallback instead of `file:` URI
redsun82 May 13, 2026
c2fc0cf
Fix Windows path handling in diagnostic relativization
redsun82 May 13, 2026
d287925
Python extractor: use relative paths in diagnostic locations
redsun82 May 13, 2026
ee13ea0
Harden `_relative_path` for Windows and mixed-form inputs
redsun82 May 13, 2026
c8efc34
C#: Update the generated lock, targets and bzl files.
michaelnebel May 13, 2026
c8196e4
Merge branch 'main' into extsensitive
geoffw0 May 13, 2026
8e25240
C++: Add a FP caused by missing certainty around SSA writes from Unin…
MathiasVP May 13, 2026
b753e7d
C++: Make 'toString' on 'Ssa::Definition' more clear.
MathiasVP May 13, 2026
e77d85f
C++: Add a new test to test assignment certainty (i.e., whether the e…
MathiasVP May 12, 2026
6d5d57a
C++: Add missing overrides.
MathiasVP May 12, 2026
fc80a24
C++: Slightly refactor certainty computation with a newtype.
MathiasVP May 12, 2026
8585bb6
C++: Some writes are always certain regardless of the address.
MathiasVP May 12, 2026
f40d42c
C++: Perform an SCC reduction to simulate greatest fixed-point semant…
MathiasVP May 12, 2026
07b8d7e
C++: Accept test changes in experimental query.
MathiasVP May 12, 2026
25c4d9d
Potential fix for pull request finding
MathiasVP May 13, 2026
b49b8ff
Give slightly more detail in change note
owen-mc May 13, 2026
3f7b50e
Type inference: Unify `getABaseTypeMention` and `conditionSatisfiesCo…
hvitved May 13, 2026
59dbd68
Add change notes.
geoffw0 May 14, 2026
c36ad7b
Adjust untrusted checkout actions queries
knewbury01 May 14, 2026
eae9c0e
Add one missing changenote actions-queries-untrusted-checkout
knewbury01 May 14, 2026
29ffd87
Add full stop to alert messages in UntrustedCheckoutHigh and Untruste…
knewbury01 May 14, 2026
914c7e1
Improve UntrustedCheckoutX helpfiles
knewbury01 May 14, 2026
3eaf04e
Fix expected files for changes to alert messages UntrustedCheckoutCri…
knewbury01 May 14, 2026
a4b2c0f
Update change notes (Copilot's suggestions).
geoffw0 May 15, 2026
336bbc2
C++: Add support for alias templates
jketema May 16, 2026
b684797
C++: Add upgrade and downgrade scripts
jketema May 16, 2026
9637158
C++: Add change note
jketema May 16, 2026
305a63b
C++: Update dbscheme stats
jketema May 16, 2026
7f1bebe
Potential fix for pull request finding
hvitved May 17, 2026
2902a19
C++: Add more scanf testing.
MathiasVP May 14, 2026
c2e2770
C++: Simplify type alias class naming
jketema May 18, 2026
9b2b597
Merge pull request #21846 from michaelnebel/csharp/updateextractordep…
michaelnebel May 18, 2026
7636bf5
Potential fix for pull request finding
jketema May 18, 2026
d14b806
Update cpp/ql/lib/semmle/code/cpp/TypedefType.qll
jketema May 18, 2026
5f65534
Update cpp/ql/lib/change-notes/2026-05-16-alias-template.md
jketema May 18, 2026
16235d7
C++: Add a 'call' column to 'hasRemoteFlowSource' and 'hasLocalFlowSo…
MathiasVP May 18, 2026
5add24b
C++: Add scanf_s models.
MathiasVP May 14, 2026
5f10a88
C++: Handle size arguments in 'getOutputArgument'.
MathiasVP May 14, 2026
19781e5
C++: Add change notes.
MathiasVP May 18, 2026
2c15699
C++: Add two more 'fopen'-like models.
MathiasVP May 18, 2026
9f64000
Post-release preparation for codeql-cli-2.25.5
invalid-email-address May 18, 2026
ad69cfb
Merge pull request #21838 from github/copilot/widen-regex-for-pinned-…
owen-mc May 18, 2026
0633bc7
Merge pull request #21862 from MathiasVP/more-fopen-models
MathiasVP May 18, 2026
01ff9aa
Swift: Update to Swift 6.3.2
jketema May 18, 2026
3119ef6
Add MaDs for Apache Avro
jacknojo May 5, 2026
22a8123
Merge pull request #21860 from jketema/jketema/alias-template
jketema May 19, 2026
adf59f3
Merge branch 'main' into redsun82/redsun82-python-absolute-paths-in-d…
redsun82 May 19, 2026
d93de54
C++: Consistent use of 'this.getIndirection()' in 'toString'.
MathiasVP May 19, 2026
06c9087
Merge branch 'main' into redsun82/issue-21802-ruby-absolute-paths-in-…
redsun82 May 19, 2026
7a1a90b
C#: Address review comment.
michaelnebel May 19, 2026
63a0948
Initial plan
Copilot May 19, 2026
b161531
Bump jackson-core to 2.18.6 in ferstl-depgraph-dependencies (CVE-2025…
Copilot May 19, 2026
96ef59a
Merge pull request #21861 from jketema/jketema/swift-6.3.2
jketema May 19, 2026
49a435c
Merge pull request #21827 from michaelnebel/csharp14/userincrementdec…
michaelnebel May 19, 2026
dc80a02
C#: Streamline the AddOperatorCall logic for prefix and postfix unary…
michaelnebel May 13, 2026
a72cef6
C#: Rename Unary to PrefixUnary.
michaelnebel May 13, 2026
30a5769
C#: Simplify and streamline the implementation of Prefix and Postfix …
michaelnebel May 13, 2026
8b799f8
Do not remove zip file if the process succeeds
oscarsj May 19, 2026
aa136a3
Add change note entry
jacknojo May 19, 2026
0a87658
Adjust name UntrustedCheckoutHigh wording trusted to privileged
knewbury01 May 19, 2026
bfc6dee
Adjust wording helpfiles UntrustedCheckoutX all three files
knewbury01 May 19, 2026
c6ce13a
C++: Simplify recursion in 'PhiCycle::isCertain' and do not restrict …
MathiasVP May 19, 2026
f77d426
C++: Add test demonstrating broken phi cycle certain'ness.
MathiasVP May 19, 2026
f5113b1
C++: Fix internal SCC edges and accept test changes.
MathiasVP May 19, 2026
c1e26f9
Merge pull request #21847 from github/redsun82/redsun82-python-absolu…
redsun82 May 19, 2026
3aa6606
Merge pull request #21806 from geoffw0/extsensitive
geoffw0 May 19, 2026
4b095f3
Merge pull request #21754 from github/jacknojo/add_llm_generated_mads…
jacknojo May 20, 2026
422a6bd
C#: Remove the prelim C# 14 footnote from the documentation.
michaelnebel May 20, 2026
462a7bc
C#: Add change-note.
michaelnebel May 20, 2026
e408540
Potential fix for pull request finding
michaelnebel May 20, 2026
b9bf81e
Merge branch 'main' into copilot/bump-jackson-core-to-2150
oscarsj May 20, 2026
157424c
Merge pull request #21836 from MathiasVP/uncertain-def-more-complete
MathiasVP May 20, 2026
e6c5f94
C++: Add missing format string part in test.
MathiasVP May 20, 2026
25d2039
C++: Add models for _scanf_s_l, wscanf_s and _wscanf_s_l.
MathiasVP May 20, 2026
a33af09
C++: Add models for _fscanf_s_l, fwscanf_s and _fwscanf_s_l.
MathiasVP May 20, 2026
fb04cd2
Add changed framework coverage reports
github-actions[bot] May 21, 2026
38a2101
update-ferstl-depgraph-dependencies.sh: address review feedback
Copilot May 21, 2026
8170c20
Fix macOS bash 3.2 heredoc-in-$() portability issue in update script
Copilot May 21, 2026
4897757
Merge pull request #21875 from github/workflow/coverage/update
owen-mc May 21, 2026
2280955
Merge pull request #21800 from knewbury01/knewbury01/adjust-actions-q…
owen-mc May 21, 2026
a84043b
Merge pull request #21844 from github/redsun82/issue-21802-ruby-absol…
redsun82 May 21, 2026
0f3c9ab
Fix remaining macOS bash 3.2 portability issues in update script (ste…
Copilot May 21, 2026
39becfd
Add Windows file path tests for `relativize_for_diagnostic`
redsun82 May 21, 2026
19f93cd
Shared CFG: update `simpleLeafNode` to exclude those with additional …
owen-mc May 21, 2026
c3bafc7
Shared CFG: allow statements for init and update of for loop
owen-mc May 21, 2026
2070daf
Java: add ForStmt wrapper class
owen-mc May 21, 2026
039b592
C#: update ForStmt wrapper class
owen-mc May 21, 2026
153fbb0
Merge pull request #21878 from github/redsun82/windows-diagnostic-pat…
redsun82 May 21, 2026
149bfd1
Merge pull request #21880 from owen-mc/shared/cfg/for-loop-stmt-init-…
owen-mc May 21, 2026
7e6b10e
Merge pull request #21879 from owen-mc/shared/cfg/simpleleafnode
owen-mc May 21, 2026
c25398e
Merge pull request #21868 from github/copilot/bump-jackson-core-to-2150
oscarsj May 21, 2026
2f8c0df
Address review feedback
knewbury01 May 21, 2026
a094a8e
Fix merge conflicts
knewbury01 May 21, 2026
5503140
Merge branch 'main' into knewbury01/adjust-actions-queries-untrusted-…
knewbury01 May 21, 2026
0ef59df
Merge pull request #21852 from knewbury01/knewbury01/adjust-actions-q…
owen-mc May 21, 2026
6d6e9c0
Util: Only compute dense ranks when needed
hvitved May 21, 2026
3ee45ff
Apply suggestion from @geoffw0
hvitved May 22, 2026
871f307
Merge pull request #21871 from michaelnebel/csharp14/updatedocumentation
michaelnebel May 22, 2026
ec7e38c
C#: Ensure that `Folder` entities exist for `Compilation` entities
hvitved May 19, 2026
5a219d1
Merge pull request #21845 from michaelnebel/csharp/unaryoperatorcleanup
michaelnebel May 22, 2026
9599f01
update codeql documentation
invalid-email-address May 22, 2026
de1cb26
Merge pull request #21890 from github/codeql-spark-run-26283874463
oscarsj May 22, 2026
a027665
C++: Add ability to see if one template was generated from another
jketema May 16, 2026
f98dfcd
C++: Add upgrade and downgrade scripts
jketema May 20, 2026
77f6cac
C++: Update stats file
jketema May 20, 2026
0e6257d
C++: Fix QLDoc wording
jketema May 21, 2026
8ad461b
C++: Add change note
jketema May 21, 2026
a7405bd
Merge pull request #21856 from MathiasVP/scanf-safe-functions
MathiasVP May 22, 2026
9685755
Merge pull request #21865 from hvitved/csharp/compilation-cwd-folder
hvitved May 22, 2026
c700076
Merge pull request #21850 from hvitved/type-inference-unify-base-type
hvitved May 22, 2026
3c4e22a
Merge pull request #21870 from jketema/jketema/generated
jketema May 22, 2026
688695c
Merge pull request #21876 from hvitved/dense-rank-short-circuit
hvitved May 22, 2026
996e791
Merge branch 'main' into post-release-prep/codeql-cli-2.25.5
oscarsj May 22, 2026
491c373
Merge pull request #21864 from github/post-release-prep/codeql-cli-2.…
oscarsj May 22, 2026
44a914e
Release preparation for version 2.25.6
invalid-email-address May 25, 2026
fe7b2b9
Merge pull request #21892 from github/release-prep/2.25.6
oscarsj May 25, 2026
9bc0c1b
Revert "Release preparation for version 2.25.6"
henrymercer May 29, 2026
f4da0df
Merge pull request #21910 from github/revert-21892-release-prep/2.25.6
henrymercer May 29, 2026
8b6f969
Release preparation for version 2.25.6
invalid-email-address May 29, 2026
1a82a68
Merge pull request #21911 from github/release-prep/2.25.6
henrymercer May 29, 2026
a9d3285
Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Jun 4, 2026
8da1376
Merge branch 'main' of https://github.com/microsoft/codeql into auto/…
Jun 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/ql/examples/snippets/uses_pinned_sha.ql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import actions

from UsesStep uses
where uses.getVersion().regexpMatch("^[A-Fa-f0-9]{40}$")
where uses.getVersion().regexpMatch("^[A-Fa-f0-9]{40}([A-Fa-f0-9]{24})?$")
select uses, "This 'uses' step has a pinned SHA version."
6 changes: 6 additions & 0 deletions actions/ql/lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.4.37

### Minor Analysis Improvements

* The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, include regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a sha1 or sha256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used.

## 0.4.36

### Minor Analysis Improvements
Expand Down
5 changes: 5 additions & 0 deletions actions/ql/lib/change-notes/released/0.4.37.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 0.4.37

### Minor Analysis Improvements

* The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, include regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a sha1 or sha256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used.
2 changes: 1 addition & 1 deletion actions/ql/lib/codeql-pack.release.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.4.36
lastReleaseVersion: 0.4.37
19 changes: 17 additions & 2 deletions actions/ql/lib/codeql/actions/Bash.qll
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,22 @@ module Bash {

/**
* Holds if the given regex is used to match an alphanumeric string
* eg: `^[0-9a-zA-Z]{40}$`, `^[0-9]+$` or `^[a-zA-Z0-9_]+$`
* eg: `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$`, `^[0-9]+$` or `^[a-zA-Z0-9_]+$`
*/
string alphaNumericRegex() { result = "^\\^\\[([09azAZ_-]+)\\](\\+|\\{\\d+\\})\\$$" }
string alphaNumericRegex() {
exists(string r1, string r2, string r3, string r4 |
// An alphanumeric character class
r1 = "\\[([09azAZ_-]+)\\]" and
// The same as above, followed by a quantifier like `+` or `{20}`
r2 = r1 + "(\\+|\\{\\d+\\})" and
// The same as above, possibly with parentheses around it
r3 = "\\(?" + r2 + "\\)?" and
// The same as above, possibly with a `?` after it
r4 = r3 + "\\??"
|
// The same as above, repeated one or more times, and with `^` at the
// beginning and `$` at the end
result = "^\\^(" + r4 + ")+\\$$"
)
}
}
2 changes: 1 addition & 1 deletion actions/ql/lib/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: codeql/actions-all
version: 0.4.36
version: 0.4.37
library: true
warnOnImplicitThis: true
dependencies:
Expand Down
19 changes: 19 additions & 0 deletions actions/ql/src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 0.6.29

### Query Metadata Changes

* Reversed adjustment of the name of `actions/untrusted-checkout/high`, but kept the portion of the previous change for the word "trusted" to "privileged". Added a missing "a" to phrasing in `actions/untrusted-checkout/high` and `actions/untrusted-checkout/medium`.

### Major Analysis Improvements

* Adjusted `actions/untrusted-checkout/critical` to align more with other untrusted resource queries, where the alert location is the location where the artifact is obtained from (the checkout point). This aligns with the other 2 related queries. This will cause the same alerts to re-open for closed alerts of this query.

### Minor Analysis Improvements

* Altered the alert message for clarity for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`.
* The `actions/unpinned-tag` query now recognizes 64-character SHA-256 commit hashes as properly pinned references, in addition to 40-character SHA-1 hashes.

### Bug Fixes

* Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on in minor point, added one more listed resource and added one more recommendation for things to check.

## 0.6.28

### Query Metadata Changes
Expand Down
4 changes: 3 additions & 1 deletion actions/ql/src/Security/CWE-829/UnpinnedActionsTag.ql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import actions
import codeql.actions.security.UseOfUnversionedImmutableAction

bindingset[version]
private predicate isPinnedCommit(string version) { version.regexpMatch("^[A-Fa-f0-9]{40}$") }
private predicate isPinnedCommit(string version) {
version.regexpMatch("^[A-Fa-f0-9]{40}([A-Fa-f0-9]{24})?$")
}

bindingset[nwo]
private predicate isTrustedOwner(string nwo) {
Expand Down
5 changes: 4 additions & 1 deletion actions/ql/src/Security/CWE-829/UntrustedCheckoutCritical.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Certain triggers automatically grant a workflow elevated privileges:
* An attacker forks the repository and adds malicious code (e.g., in the build script)
* The attacker opens a PR from the fork, and, if needed, comments on the PR
* The workflow in the base repository checks out the forked code
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
* The workflow runs the malicious code

Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.

Expand All @@ -41,6 +41,8 @@ The best practice is to handle the potentially untrusted pull request via the **

The artifacts downloaded from the first workflow should be considered untrusted and must be verified.

Additionally, ensure that least privilege are used both at the workflow level (through event triggers and workflow permissions) and job level (through job permissions).

## Example

### Incorrect Usage
Expand Down Expand Up @@ -163,4 +165,5 @@ jobs:

- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
- Securing with least privilege: [Workflow secure use](https://docs.github.com/en/actions/reference/security/secure-use).
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).
5 changes: 3 additions & 2 deletions actions/ql/src/Security/CWE-829/UntrustedCheckoutCritical.ql
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ where
event.getName() = checkoutTriggers() and
not exists(ControlCheck check | check.protects(checkout, event, "untrusted-checkout")) and
not exists(ControlCheck check | check.protects(poisonable, event, "untrusted-checkout"))
select poisonable, checkout, poisonable,
"Potential execution of untrusted code on a privileged workflow ($@)", event, event.getName()
select checkout, checkout, poisonable,
"Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: $@).",
event, event.getName()
5 changes: 4 additions & 1 deletion actions/ql/src/Security/CWE-829/UntrustedCheckoutHigh.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Certain triggers automatically grant a workflow elevated privileges:
* An attacker forks the repository and adds malicious code (e.g., in the build script)
* The attacker opens a PR from the fork, and, if needed, comments on the PR
* The workflow in the base repository checks out the forked code
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
* The workflow runs the malicious code

Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.

Expand All @@ -41,6 +41,8 @@ The best practice is to handle the potentially untrusted pull request via the **

The artifacts downloaded from the first workflow should be considered untrusted and must be verified.

Additionally, ensure that least privilege are used both at the workflow level (through event triggers and workflow permissions) and job level (through job permissions).

## Example

### Incorrect Usage
Expand Down Expand Up @@ -163,4 +165,5 @@ jobs:

- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
- Securing with least privilege: [Workflow secure use](https://docs.github.com/en/actions/reference/security/secure-use).
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).
7 changes: 4 additions & 3 deletions actions/ql/src/Security/CWE-829/UntrustedCheckoutHigh.ql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @name Checkout of untrusted code in privileged context without privileged context use
* @name Checkout of untrusted code in a privileged context
* @description Privileged workflows have read/write access to the base repository and access to secrets.
* By explicitly checking out and running the build script from a fork the untrusted code is running in an environment
* that is able to push to the base repository and to access secrets.
Expand Down Expand Up @@ -42,5 +42,6 @@ where
not event.getName() = "issue_comment" and
not exists(ControlCheck check | check.protects(checkout, event, "untrusted-checkout"))
)
select checkout, "Potential execution of untrusted code on a privileged workflow ($@)", event,
event.getName()
select checkout,
"Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: $@).",
event, event.getName()
5 changes: 4 additions & 1 deletion actions/ql/src/Security/CWE-829/UntrustedCheckoutMedium.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Certain triggers automatically grant a workflow elevated privileges:
* An attacker forks the repository and adds malicious code (e.g., in the build script)
* The attacker opens a PR from the fork, and, if needed, comments on the PR
* The workflow in the base repository checks out the forked code
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
* The workflow runs the malicious code

Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.

Expand All @@ -41,6 +41,8 @@ The best practice is to handle the potentially untrusted pull request via the **

The artifacts downloaded from the first workflow should be considered untrusted and must be verified.

Additionally, ensure that least privilege are used both at the workflow level (through event triggers and workflow permissions) and job level (through job permissions).

## Example

### Incorrect Usage
Expand Down Expand Up @@ -163,4 +165,5 @@ jobs:

- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
- Securing with least privilege: [Workflow secure use](https://docs.github.com/en/actions/reference/security/secure-use).
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).
2 changes: 1 addition & 1 deletion actions/ql/src/Security/CWE-829/UntrustedCheckoutMedium.ql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @name Checkout of untrusted code in trusted context
* @name Checkout of untrusted code in a trusted context
* @description Privileged workflows have read/write access to the base repository and access to secrets.
* By explicitly checking out and running the build script from a fork the untrusted code is running in an environment
* that is able to push to the base repository and to access secrets.
Expand Down
18 changes: 18 additions & 0 deletions actions/ql/src/change-notes/released/0.6.29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## 0.6.29

### Query Metadata Changes

* Reversed adjustment of the name of `actions/untrusted-checkout/high`, but kept the portion of the previous change for the word "trusted" to "privileged". Added a missing "a" to phrasing in `actions/untrusted-checkout/high` and `actions/untrusted-checkout/medium`.

### Major Analysis Improvements

* Adjusted `actions/untrusted-checkout/critical` to align more with other untrusted resource queries, where the alert location is the location where the artifact is obtained from (the checkout point). This aligns with the other 2 related queries. This will cause the same alerts to re-open for closed alerts of this query.

### Minor Analysis Improvements

* Altered the alert message for clarity for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`.
* The `actions/unpinned-tag` query now recognizes 64-character SHA-256 commit hashes as properly pinned references, in addition to 40-character SHA-1 hashes.

### Bug Fixes

* Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on in minor point, added one more listed resource and added one more recommendation for things to check.
2 changes: 1 addition & 1 deletion actions/ql/src/codeql-pack.release.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.6.28
lastReleaseVersion: 0.6.29
2 changes: 1 addition & 1 deletion actions/ql/src/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: codeql/actions-queries
version: 0.6.28
version: 0.6.29
library: false
warnOnImplicitThis: true
groups: [actions, queries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ jobs:
- uses: foo/bar@25b062c917b0c75f8b47d8469aff6c94ffd89abb
- uses: docker://foo/bar@latest
- uses: docker://foo/bar@sha256:887a259a5a534f3c4f36cb02dca341673c6089431057242cdc931e9f133147e9
# SHA-256 pinned (64 hex chars) - should NOT be flagged
- uses: foo/bar@25b062c917b0c75f8b47d8469aff6c94ffd89abb25b062c917b0c75f8b47d84d
# SHA-1 pinned (40 hex chars) regression - should NOT be flagged
- uses: foo/bar@a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2
# Invalid 50-char hex string - should be flagged
- uses: foo/bar@a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2a1b2c3d4e5
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
| .github/workflows/test18.yml:37:21:37:63 | sonarsource/sonarcloud-github-action@master | Unpinned 3rd party Action 'Sonar' step $@ uses 'sonarsource/sonarcloud-github-action' with ref 'master', not a pinned commit hash | .github/workflows/test18.yml:36:15:40:58 | Uses Step | Uses Step |
| .github/workflows/unpinned_tags.yml:10:13:10:22 | foo/bar@v1 | Unpinned 3rd party Action 'unpinned_tags.yml' step $@ uses 'foo/bar' with ref 'v1', not a pinned commit hash | .github/workflows/unpinned_tags.yml:10:7:11:4 | Uses Step | Uses Step |
| .github/workflows/unpinned_tags.yml:12:13:12:35 | docker://foo/bar@latest | Unpinned 3rd party Action 'unpinned_tags.yml' step $@ uses 'docker://foo/bar' with ref 'latest', not a pinned commit hash | .github/workflows/unpinned_tags.yml:12:7:13:4 | Uses Step | Uses Step |
| .github/workflows/unpinned_tags.yml:19:13:19:70 | foo/bar@a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2a1b2c3d4e5 | Unpinned 3rd party Action 'unpinned_tags.yml' step $@ uses 'foo/bar' with ref 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2a1b2c3d4e5', not a pinned commit hash | .github/workflows/unpinned_tags.yml:19:7:19:71 | Uses Step | Uses Step |
Loading
Loading