Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e898549
refs: give detectors a Dockerfile's instructions, as java4shell does
devGregA Nov 18, 2026
2ecf205
nginxh2: FACTS.md for the nginx HTTP/2 pair, CVE-2026-123007 and CVE-…
devGregA Nov 18, 2026
9dec68a
nginxh2: judge nginx binaries and their HTTP/2 exposure in filesystem…
devGregA Nov 18, 2026
62dab54
nginxh2: tests for versions, binaries, configuration, package databas…
devGregA Nov 18, 2026
6a51032
nginxh2: gofmt
devGregA Nov 18, 2026
8ae8689
nginxh2: fuzz the configuration parser, the binary reader and the ver…
devGregA Nov 18, 2026
1ad67b1
nginxh2: scan repo and fix (WIP)
devGregA Nov 18, 2026
4795524
nginxh2: source-tree scan and fix
devGregA Nov 18, 2026
6ecb5b0
nginxh2: Alpine's fixed package, generated ingress configurations, pa…
devGregA Nov 18, 2026
d3609a1
nginxh2: parity against published images (39 cases)
devGregA Nov 18, 2026
1c4a25e
nginxh2: FACTS.md records the F5 controller images read
devGregA Nov 18, 2026
4fe36dd
nginxh2: README entry, usage, layout, parity and fuzz commands
devGregA Nov 18, 2026
03e514b
nginxh2: fixes from the independent review
devGregA Nov 18, 2026
dbfb0ac
engine, nginxh2: a scan can see what the walk did not read; nginxh2 n…
devGregA Nov 18, 2026
e38ecd8
nginxh2: exposure reads as off only when the command that starts ngin…
devGregA Nov 18, 2026
572ed1e
nginxh2: a deployment that changes an image's command or configuratio…
devGregA Nov 18, 2026
6d14c98
nginxh2: unset template variables anywhere in listen, or standing for…
devGregA Nov 18, 2026
9542ca5
nginxh2: a version on a line newer than any known is unknown, never f…
devGregA Nov 18, 2026
82f8430
nginxh2: built without HTTP/2 needs both witnesses read whole; HTTP/2…
devGregA Nov 18, 2026
5f0b7f2
nginxh2: bound what all included files together make the loader parse
devGregA Nov 18, 2026
bddc3e1
nginxh2: fix verifies a tag move on the FROM line's own --platform
devGregA Nov 18, 2026
49c96e3
nginxh2: nothing nginx-shaped in a source tree is passed over in silence
devGregA Nov 18, 2026
cbdfd3b
nginxh2: POSIX classes in include globs, hard-linked sites, more ways…
devGregA Nov 18, 2026
df87f28
nginxh2: fix reads each image pair once, checks Alpine's index before…
devGregA Nov 18, 2026
5176731
nginxh2: wording without certainty; YAML read errors are not checked
devGregA Nov 18, 2026
c4289c8
nginxh2: fuzz the include glob and link resolver, templates, units, t…
devGregA Nov 18, 2026
e1935f2
nginxh2: FACTS.md states the round-2 rules and the Tengine 2.x source…
devGregA Nov 18, 2026
743f94a
nginxh2: parity expectations for images whose command does not start …
devGregA Nov 18, 2026
fbc1ad2
nginxh2: parity results after review 2 (39/39)
devGregA Nov 18, 2026
cddd172
nginxh2: FACTS.md cites the vendor pages the lead read on 2026-11-18
devGregA Nov 18, 2026
1d6a1d6
nginxh2: trust an entrypoint by its content, and its scripts only whe…
devGregA Nov 18, 2026
46b1a9d
nginxh2: a host's systemd unit is read with every drop-in and overrid…
devGregA Nov 18, 2026
39b163c
nginxh2: deployment changes reach the image through FROM aliases, Hel…
devGregA Nov 18, 2026
7ed8ef6
nginxh2: the template-variable check reads directive names only, as w…
devGregA Nov 18, 2026
1295d7a
nginxh2: an older core whose HTTP/2 witness is cut or missing is unknown
devGregA Nov 18, 2026
6a2cd2e
nginxh2: an nginx call that tests, shows or signals is not the start
devGregA Nov 18, 2026
2eec66b
nginxh2: bound the loader's and the include globs' time, not only memory
devGregA Nov 18, 2026
fe7f6e7
nginxh2, engine: verification nits
devGregA Nov 18, 2026
3ea9a89
nginxh2: FACTS.md states the round-3 rules
devGregA Nov 18, 2026
6cea9f3
engine, nginxh2: resolve a relative command word as the runtime does …
devGregA Nov 19, 2026
208ed3f
nginxh2: follow directory links inside /docker-entrypoint.d as find -…
devGregA Nov 19, 2026
cc48a93
nginxh2: apply a unit's Environment and EnvironmentFile to ExecStart;…
devGregA Nov 19, 2026
09fc25c
nginxh2: read a Helm chart's templates in every subdirectory
devGregA Nov 19, 2026
3df0647
nginxh2: index the unit directories once per scan
devGregA Nov 19, 2026
bf463d1
nginxh2: below a system root, a wildcard-directory glob reads the disk
devGregA Nov 19, 2026
a41b58a
nginxh2: the missing-platform sentence reads whole
devGregA Nov 19, 2026
62876b8
nginxh2: FACTS.md states the round-4 rules and what a tree cannot show
devGregA Nov 19, 2026
ee99b03
nginxh2: fuzz the unit environment, the command resolver and the entr…
devGregA Nov 19, 2026
6712e9f
nginxh2: "not exposed" only when the start, the entrypoint and every …
devGregA Nov 19, 2026
74440d3
nginxh2: templates the scan cannot apply exactly leave exposure unknown
devGregA Nov 19, 2026
04648d4
nginxh2: wildcard-directory globs keep links and read errors as incom…
devGregA Nov 19, 2026
f3ebd84
nginxh2: a timing test for the entrypoint walk
devGregA Nov 19, 2026
9a02232
nginxh2: unit settings the scan cannot apply exactly leave exposure u…
devGregA Nov 19, 2026
c2ec154
nginxh2: scan repo reads subchart templates and names links by tree path
devGregA Nov 19, 2026
29dcb8a
nginxh2: the fuzzed launcher reaches the entrypoint directory walk
devGregA Nov 19, 2026
554e45b
nginxh2: FACTS and README state the round-5 rule for "not exposed"
devGregA Nov 19, 2026
1352eb3
nginxh2: parity under the round-5 rule; nginx-debug not started is un…
devGregA Nov 19, 2026
c7a2cde
Merge main (java4shell, #9) into nginxh2
devGregA Nov 19, 2026
17c91b1
engine: SkipVisitor gets the walk's gaps one record per path
devGregA Nov 19, 2026
afd68ac
ci: fuzz the nginxh2 targets like the other fuzzers
devGregA Nov 19, 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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
go test ./detectors/java4shell/internal/assess -run '^$' -fuzz '^FuzzDpkgOwners$' -fuzztime 15s
go test ./detectors/java4shell/internal/assess -run '^$' -fuzz '^FuzzRun$' -fuzztime 30s
go test ./detectors/java4shell -run '^$' -fuzz '^FuzzReadCrash$' -fuzztime 15s
go test ./detectors/nginxh2 -run '^$' -fuzz '^FuzzSource$' -fuzztime 30s
go test ./detectors/nginxh2/internal/assess -run '^$' -fuzz '^FuzzStart$' -fuzztime 20s
go test ./detectors/nginxh2/internal/conf -run '^$' -fuzz '^FuzzParse$' -fuzztime 30s
go test ./detectors/nginxh2/internal/ngx -run '^$' -fuzz '^FuzzInspect$' -fuzztime 20s
go test ./detectors/nginxh2/internal/ngx -run '^$' -fuzz '^FuzzVersions$' -fuzztime 15s
go test ./detectors/nginxh2/internal/pkgdb -run '^$' -fuzz '^FuzzDatabases$' -fuzztime 15s
go test ./detectors/nginxh2/internal/repo -run '^$' -fuzz '^FuzzScanText$' -fuzztime 20s
for f in FuzzParseDpkgStatus FuzzParseAPKInstalled FuzzParseHeaderBlob FuzzReadBDB FuzzReadNDB FuzzResolver; do
go test ./detectors/php2shell/internal/pkgdb -run '^$' -fuzz "^$f\$" -fuzztime 15s
done
Expand Down
17 changes: 16 additions & 1 deletion README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions detectors/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
_ "github.com/DefectDojo/earlylight/detectors/brotli"
_ "github.com/DefectDojo/earlylight/detectors/emudhra"
_ "github.com/DefectDojo/earlylight/detectors/java4shell"
_ "github.com/DefectDojo/earlylight/detectors/nginxh2"
_ "github.com/DefectDojo/earlylight/detectors/php2shell"
_ "github.com/DefectDojo/earlylight/detectors/sshole"
)
163 changes: 163 additions & 0 deletions detectors/nginxh2/FACTS.md

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions detectors/nginxh2/apkindex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package nginxh2

import (
"archive/tar"
"bufio"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"net/http"
"regexp"
"strings"
"time"

"github.com/DefectDojo/earlylight/internal/engine"
"github.com/DefectDojo/earlylight/internal/netguard"
)

// apkMirror is where fix reads an Alpine branch's package index.
const apkMirror = "https://dl-cdn.alpinelinux.org/alpine"

// maxAPKIndex bounds the index fix reads (main/x86_64 is a few MiB).
const maxAPKIndex = 32 << 20

var apkBranch = regexp.MustCompile(`^(?:edge|3\.\d{1,2})$`)

// apkIndex returns the nginx version in an Alpine branch's main index,
// read through the guarded transport within the timeout.
func apkIndex(o engine.Options) func(context.Context, string) (string, error) {
return func(ctx context.Context, branch string) (string, error) {
if !apkBranch.MatchString(branch) {
return "", fmt.Errorf("%q is not an Alpine branch", branch)
}
dir := branch
if branch != "edge" {
dir = "v" + branch
}
timeout := o.Timeout
if timeout <= 0 {
timeout = 60 * time.Second
}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, apkMirror+"/"+dir+"/main/x86_64/APKINDEX.tar.gz", nil)
if err != nil {
return "", err
}
resp, err := (&http.Client{Transport: netguard.Transport(o.PublicOnly)}).Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("%s: HTTP %d", req.URL, resp.StatusCode)
}
return nginxInIndex(io.LimitReader(resp.Body, maxAPKIndex))
}
}

// nginxInIndex reads the nginx package's version from an APKINDEX.tar.gz.
func nginxInIndex(r io.Reader) (string, error) {
gz, err := gzip.NewReader(r)
if err != nil {
return "", err
}
// The index is a gzip stream of signature then index; read on
// through every member.
gz.Multistream(true)
tr := tar.NewReader(gz)
for {
h, err := tr.Next()
if err != nil {
if errors.Is(err, io.EOF) {
return "", errors.New("the index has no APKINDEX file")
}
return "", err
}
if h.Name != "APKINDEX" {
continue
}
sc := bufio.NewScanner(io.LimitReader(tr, maxAPKIndex))
sc.Buffer(make([]byte, 64<<10), 1<<20)
pkg := ""
for sc.Scan() {
l := sc.Text()
switch {
case l == "":
pkg = ""
case strings.HasPrefix(l, "P:"):
pkg = l[2:]
case strings.HasPrefix(l, "V:") && pkg == "nginx":
return l[2:], nil
}
}
if err := sc.Err(); err != nil {
return "", err
}
return "", errors.New("the index lists no nginx package")
}
}
84 changes: 84 additions & 0 deletions detectors/nginxh2/entrypoints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package nginxh2

// officialScripts are the SHA-256 of every version of the official nginx
// image's entrypoint and /docker-entrypoint.d scripts, by file name, in
// the history of github.com/nginx/docker-nginx and
// github.com/nginx/docker-nginx-unprivileged (read 2026-11-18). A script
// is trusted only by its content.
var officialScripts = map[string]map[string]bool{
"10-listen-on-ipv6-by-default.sh": {
"049df3929188dcce3f370da602ada4dbcde7e80b774d3f340f5994cc077e53de": true,
"1431651f608f7e4b33215dec67a1c623cd47a43ab1e783fdcdb5f6ff6e55f7dd": true,
"1ccc7715f8f454b0a1fa43a2b8f3d53778bbadaa3f60662f13f23cc664381cde": true,
"1decbf35705a305ffd6ba18164f7c9af8ee7d3fcf5cb36dd43ea3df58d6a743d": true,
"2f4b260a8a8320ba66d540798898771959de84f16f49f3df1ff22cefbeca8793": true,
"3b1efb4263e482d897d61024b6af352d7e20e950958b462275685161bf550a27": true,
"3e02c931b3adf55e3952e14bdd6cdf5af6341aed658cd5bad3185b47470dc590": true,
"5aeea461961fea4f6cefeca53c6b2cf80275f65fb9787af7e62ff47d7158c48b": true,
"6af73d816765f1a163eff548e120e9cfad5053776ca7c67d0966cdfaafc652dc": true,
"82d049f268c293e0cdbdfd6185683a21fc8f032a8c70aa32534c055f5b28e91c": true,
"8c5d2c912416126c7d65651600b166c00ad9ca3e3af82487ddd5a5da94fb8fb5": true,
"91c84252278f74e5b22f9c573464994691bd4e0b2b7196315342979d49722f79": true,
"95ac0282b4f4841d47f57d1cf8c81334e3d143ff6f8a5df7ca8be5d6e100377c": true,
"9d36e71af5e9adcbf7e4f92835eef678b4b475dfe0838d48ece4445641452c26": true,
"a04b7d0da99a1fc75abfbba9ea9ca371283bd63ed4c242b87705409e8557a591": true,
"a0cd7b5f4f2eca6c416c5f3e64af9b4bedcad1145a61a940159ef2e08a92cc67": true,
"a267cc710deae9a11278c784655c31b6e375fd8c55f1b79c6de948a35280bfe8": true,
"a493f7d754e12a5e8e9c5174c4caa9289296c56b5215be747965a34cbee8b818": true,
"b18798299833e0089b06ad6af65ed23547a922cbe6bbd2358b88a9e8b92fa682": true,
"c4b740384b88b86bc84ecf4237167b16d09d6e35cf9564b676ba1fd0249f6fcc": true,
"c6b6a5501e6fcf309d26a2bf584df9a3b42c626447b417d2d002d2227a9208a4": true,
"d09a9874ae89162d72b53b541eeca42c0f74fc0e881da516f1eb226c460319de": true,
"d2a29aae11e6684ef917182bff5a306cbcf5debc872645d4c35b8b457d364e69": true,
"db9d8be6f3ea527a22c22bdf7fff1f3bcdb3be61a75e5d3e84d128665af33cc4": true,
"dbc37e03540c6641ec3e006a95586ca0da61368659d92546faee54509bd6ad19": true,
"dd39eedf150f68f5e7a4fb9f1637faa7ae26bc56daf97cb90b0c429a4cfedb87": true,
"e296e115fc8e0865145f304db80b773da456692df1fdb4c5fdd435f20a213533": true,
"fe712628e80fc0a52c0bede8071d872a8d5401cee8592bfb58e76e3232baa1fd": true,
},
"15-local-resolvers.envsh": {
"18cb166b07aac0992725ca6eace13f2386f4f8eda16fece504303d4acc258cbf": true,
"329a1e89cc898599338874f679e22711c4c2d69f65f98b64a72d8b708e69ee44": true,
"3659a4a271496f6a8f0785a1d7e57a9348803e90c08fe57431fe3ee19b010644": true,
"93078c67574883131f8afdbb27c20173674358ca63e4ef67c0fee10429d64c1a": true,
"ac3cca51e959ed97b20ca10a38a24b8404e52f7de50d414a96118902c7858a33": true,
},
"20-envsubst-on-templates.sh": {
"00d6d14424342d6a3439f4d7af190bfc33b96f40221946b174a6c7385ee3b98c": true,
"253c8724acff9f5c0d0e8938e71fe7c33097d40031a5bc9c7f59dfd2ba5f1377": true,
"372dc96ddf9b2d7c8a974f43c61e77efef539d5f6f8903197987523bc4b31000": true,
"37eb458e54b5c3defd6cb62d15456ba961f5e322c6c50662b81f366a743614e9": true,
"3a2ac24c7e19fe0ab81a7f2ef469cf01a2e86f85802d2e6cbc5d9579cad8ea88": true,
"54ccb0807c9fbde4b23614da27d5071c5a49a2c0c3be419e3f5c2d6c46acc140": true,
"7740f9a27ae6ce89b7c0dc0e8224bc0b9ed364e2440604356468fd8d2c50cc59": true,
"97a871eb3192f4913a9bedd5f4597552f053319a0a54cc65146da27b675b4a53": true,
"ac517b7fe85e59c26241469c89e825305b007566f2dd9b7238fcc3bc36089209": true,
"c62d8bd0c11f43942253ec2e75b9727b69c6cbf598be6517d39ec63fa086b2bf": true,
"ce71637f0fb7a4c2c363f901226af65655e448070ed43a5d43d56449a74d9e75": true,
"d019545eecafccc67a62aba7b351fc83e20f7220a404ba0fb9f02c4e409698f1": true,
"d88f37ff868d0e47c90feaead5f1138a5e6b8a046440e5a8399e091e3e94e239": true,
"e9c68630816e6b8f58a4993b4c43be80c230f44260bb33d3b26738a99e43512c": true,
"f2dd783ed775bc923fe79dd0568c18670d74b0fdc462ff7f3c6343e676f5f671": true,
"fe5c125274976088179762f7918b1a02a1aa1eb5ccad8fd1b46d7d46287410f2": true,
},
"30-tune-worker-processes.sh": {
"1b99cae15627930024f6f942f0f1744671814de5398ebe9cb65c6ceb9d0a18cf": true,
"1f068aa49da8df46bfd5a917debf110af9b115370739e3be34af83ebf583fbce": true,
"77cf5b2f9a80f0ecf860a6c0f69efa5879b8afdadef24e15cf14d32bde463fcd": true,
"a0f53c5bf9b043b6d14f0643965dabd19059f25ef2cba34b3da53a1cb2dd782c": true,
"b8f0d3f5b52987b19c4875789999372ef45ba1dc9a1849a8737268e7812e5d5e": true,
},
"docker-entrypoint.sh": {
"026ebfe1f5b9a951c519f040dbcf3f7274e49bfc9eaadb449a9d6f80beed4939": true,
"220b6ae8317ca4c7326158e8246e5f9f45c2bfe3c8792423ba8d6ad61bfa77b6": true,
"324df58250bdb0b35678bcba147282736e2511c46fa1487f48dd394250c91cd3": true,
"3372fd90162da30d09f62c245e9c6bfd620fb0bb5b48ab54b16e804c2b9e8aae": true,
"50a4ca27f8f73ba446478d44b7e0734003c717164b6b7f49077dba708cf8543b": true,
"698acdc803486bbe6a9ab9951e353467584acaade53b112aef2274da3060c598": true,
"81cdfd1ebdd7717981e2a92f563350a7ce012bdcb8a5a62e6521caa6ce600b67": true,
"b288af423e84fd92b50ec944e593ef2505c831a43c639163dadc9db2b4105f1b": true,
"c14d3511ddb4d34fbe3a377a87f70efbd68831bf3f3ad28f67594fe32e0361b6": true,
"caa180b65c1957815db934968c1ee079771fa64f52dae45cc0778015f7cfdc22": true,
"fbb111dbfd1efb9f34e485ba5b1ba243c60561d8d43e64c803ea6ae3b55bcb51": true,
},
}
56 changes: 56 additions & 0 deletions detectors/nginxh2/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package nginxh2

import (
"path"
"strings"
"testing"
)

// FuzzSource: the glob matcher, the symbolic link resolver, template
// substitution and the systemd unit reader take any input without a panic
// or an unbounded loop.
func FuzzSource(f *testing.F) {
f.Add("/etc/nginx/conf.d/[[:digit:]]*.conf", "/etc/nginx/conf.d/10-a.conf", "/etc/nginx/conf.d=../x;/x=/etc", "listen ${A} $B;", "A=1", "ExecStart=-/usr/sbin/nginx -g 'daemon on;'")
f.Add("/a/[!_]*", "/a/.b", "/a=/a", "${", "=", "ExecStart=\nExecStart=nginx \\")
f.Add("/usr/sbin/nginx", "/docker-entrypoint.d/40-x.sh", "/docker-entrypoint.d/sub=/etc;/usr/bin/nginx=../sbin/nginx", "", "PATH=/usr/bin", "#!/bin/sh\n")
// The launcher is the official entrypoint, so the fuzzed file in
// /docker-entrypoint.d and the links reach the directory walk.
ep := official(f, "docker-entrypoint.sh")
tpl := official(f, "20-envsubst-on-templates.sh")
f.Fuzz(func(t *testing.T, pattern, p, links, tmpl, env, unit string) {
globMatch(pattern, p)
posixClasses(pattern)
lm := map[string]string{}
for _, kv := range strings.Split(links, ";") {
if k, v, ok := strings.Cut(kv, "="); ok && len(lm) < 32 {
lm[path.Clean("/"+k)] = v
}
}
s := &confSource{kept: map[string][]byte{p: []byte(tmpl)}, links: lm, hardlinks: map[string]string{p: pattern}}
s.resolve(p)
s.Read(p)
s.Glob(pattern)
envsubst([]byte(tmpl), strings.Split(env, ","))
unitWords(unit)
us := &scan{db: map[string][]byte{"/lib/systemd/system/nginx.service": []byte(unit), "/etc/systemd/system/nginx.service.d/a.conf": []byte(tmpl)}}
us.systemdStarts(&confSource{links: lm})
nginxTest(unitWords(unit))
vars, _ := envFile([]byte(tmpl))
expandUnit(unit, vars)
unsetVar(unit, vars)
execPrefix(unit)
harmless(unitWords(unit), "/run/nginx.pid", "/usr/sbin/nginx")
resolveCommand(p, pattern, strings.Split(env, ","), func(q string) bool { return q == pattern })
fuzzed := "/docker-entrypoint.d/" + path.Base(p)
ls := &scan{db: map[string][]byte{"/docker-entrypoint.d/20-envsubst-on-templates.sh": tpl},
scripts: map[string][]byte{"/docker-entrypoint.sh": ep, fuzzed: []byte(unit)},
epSeen: map[string]bool{fuzzed: true, "/docker-entrypoint.d/" + path.Base(pattern): true}}
cmds := ls.commands(lm, nil, pattern, strings.Split(env, ","), nil)
ok, _ := cmds.launcher("/docker-entrypoint.sh")
cmds.launcher(p)
cmds.starts(p, pattern)
if b := path.Base(p); ok && b != "." && b != "/" && !strings.Contains(b, "/") && !officialScripts[b][sha([]byte(unit))] && len(lm) == 0 {
t.Fatalf("the entrypoint passed with %s not official", fuzzed)
}
})
}
Loading
Loading