add-and-commit commits a nested git repository as a gitlink chosen by an outside contributor
Description
Improper Check for Unusual or Exceptional Conditions (CWE-754) in add-and-commit, in src/main.ts, from 5.0.0 before 11.0.0. A contributor who controls a directory under the add pathspec can put a gitlink of their choosing into the commit the action makes.
The add input takes the arguments for git add and has the default .. add-and-commit parses that input with matchGitArgs() and hands the result to simple-git. The README says the input takes every kind of git argument.
add() in src/main.ts, at lines 220 to 258 in 10.0.0, calls git.add(matchGitArgs(args), (err, data) => log(...)). simple-git builds that task with straightThroughStringTask, whose parser takes one argument. callTaskParser passes stdout and stderr to the parser, and a one-argument parser returns stdout alone. isTaskError is exitCode && stdErr.length, so a zero exit code raises no error, whatever stderr contains. The callback then runs as cb(null, stdOut).
git add records a directory that has its own nested .git directory as a gitlink. The index entry has mode 160000 and names the commit at the nested repository's HEAD, and git stores none of the files inside the directory. git writes a warning and the remediation hints to stderr, and exits 0.
The value reaches the action in a workflow that checks out pull request content and then runs the action over a pathspec that covers the checked-out tree. Whoever opens the pull request supplies the directory and the commit the gitlink names.
log() in src/util.ts is if (data) console.log(data) and if (err) core.error(err). Both arguments are empty, so the job log shows the line > Adding files... and no warning. add() never reads the staged entries back, so the commit keeps the gitlink.
Vulnerability type (CWE)
- CWE-754: Improper Check for Unusual or Exceptional Conditions
Affected versions
add-and-commit from 5.0.0 before 11.0.0. Default status: unaffected.
5.0.0, released 2020-09-27, is the first version that runs git inside the action's own process through simple-git. 4.4.0 and everything earlier start git add in a child process whose stderr reaches the job log, so git's warning is visible there. 11.0.0, released 2026-08-09, is the first version that reads the staged entries back and stops the commit.
Checked by reading every one of the 51 semver tags. The add input has the default . at every release from 4.0.0 on, and path is the name of the same input before 4.0.0. Because the range starts at 5.0.0, the input has one name throughout. At all 29 releases from 5.0.0 up to 11.0.0, add() calls simple-git add with a two-argument callback into log(). No built bundle at any of those releases contains 160000, diff --cached or ls-files --stage. findUnexpectedGitlinks first appears at 11.0.0.
With git 2.39.5, git add . over a working tree that has a nested repository exits 0 and stages one entry of mode 160000. That command writes 0 bytes to stdout and 567 bytes over 14 lines to stderr. git diff --cached --raw prints an old mode of 000000 and a new mode of 160000 for that entry. The commit name stored there equals the HEAD of the nested repository.
Score (CVSS 4.0)
Medium (6.3)
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N
Attack Vector is Network, because the pull request with the directory arrives over the network. The contributor adds a nested .git directory and does no work specific to one target, so Attack Complexity is Low. Attack Requirements is Present, because the attack depends on a workflow that checks out pull request content and runs the action over a pathspec that covers that content. The contributor needs no privilege on the target repository, so Privileges Required is None. User Interaction is None, because the workflow starts the action and the action commits with no person acting.
Confidentiality on the vulnerable system is None, because the action reads nothing out and returns nothing. Integrity is Low, because the write reaches one tree entry, whose path and commit name the contributor sets, and git stores none of the files under that path. Availability is None, because the job finishes and the action goes on working. The subsequent system is the remote repository. Confidentiality, integrity and availability on the subsequent system are all None, because the gitlink is inside the repository the action commits to.
Solution
Upgrade to add-and-commit 11.0.0 or later.
On an affected version, delete every nested .git directory from the working tree before the action runs. A second option is to narrow the add pathspec to the paths the workflow writes.
Patch
Commit ebc24bf, through pull request #761, released in 11.0.0.
The commit adds findUnexpectedGitlinks and assertNoUnexpectedGitlinks to src/util.ts, 41 lines. findUnexpectedGitlinks reads the output of git diff --cached --raw and returns every path whose new mode is 160000 and whose old mode is something else. assertNoUnexpectedGitlinks throws on a non-empty list and names each path with a git rm --cached line. findUnexpectedGitlinks skips a path that is already a gitlink, so an update to a tracked submodule still commits.
add() in src/main.ts gains three lines that run git diff --cached --raw after the last git add and pass the output to the two new functions, plus two import lines. The commit also adds 86 lines to test/util.test.ts and 2 lines to README.md, and rebuilds lib/index.js: 135 added lines and 1 deleted line over 5 files.
Credits
- Lois del Río Somoza (finder)
- Xoán M. Otero Jorge (analyst)
- Darío Rivas Quero (analyst)
- Secur0 CNA (coordinator)
- Federico Grandi @EndBug (remediation developer)
Discovery source: External
Official record: CVE-2026-144938
Related records
- CVE-2026-142541 (the same product and the same range, through the
new_branchinput) - CVE-2026-142525 (the same product, where user input reaches the job log unescaped)