Overview
| Artifact ID: | 0e8fecddd50fdce1e6ab4a9ba6b87fdeb2a677db48087a4461786e71c9fc3220 |
|---|---|
| Ticket: | 3d978e0a84738b5c6a7bb1afc01aef962e9a25a4
`clock -timezone` escapes safe interp via `~` path (8.6.16+, same gap as [2f8bb48009]) |
| User & Date: | bef on 2026-11-03 11:05:41 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-markdown"
- comment changed to:
Follow-up to [2f8bb48009](https://core.tcl-lang.org/tcl/tktview/2f8bb48009). That fix added `~` to msgcat's locale check, but clock's own guard in `LoadTimeZoneFile` (and `LoadZoneinfoFile`) still uses `{^[/\\]|^[a-zA-Z]+:|(?:^|[/\\])\.\.}`, which does not reject a leading `~`. `[clock]` is aliased into safe interpreters and runs in the parent; on 8.6, `file join $DataDir ~/x` returns `~/x` and `source` expands it. So a safe child can make the parent `source` any file below a home directory. No `.msg` suffix is appended and the name is not lowercased. PoC (Tcl 8.6.18, core-8-6-branch head 52a3c1d31a): ```tcl file mkdir ~/tcldemo set fd [open ~/tcldemo/tz w] puts $fd {puts "PWNED issafe=[interp issafe] ns=[namespace current] exec=[info commands exec]"} close $fd catch {interp eval [interp create -safe] {clock format 0 -timezone :~/tcldemo/tz}} file delete ~/tcldemo/tz ``` Output: ``` PWNED issafe=0 ns=::tcl::clock exec=exec ``` `-timezone ~/tcldemo/tz` (without colon), `-t`, and `clock scan` / `clock add` reach the same code. 9.0 and 9.1 are not affected (`file join` leaves `~` literal there). This is a regression from [67e7522bd1](https://core.tcl-lang.org/tcl/info/67e7522bd1) (fix for [2c237beffbace823](https://core.tcl-lang.org/tcl/tktview/2c237beffbace823), `Etc/GMT±n`), first released in 8.6.16. Before that, the guard was the allowlist `^[[.-.][:alpha:]_]+(?:/[[.-.][:alpha:]_]+)*$`, which rejected `~`. The `clock-1.5.1-*` tests cover `..`, `//`, `zipfs:` and `C:`, but not `~`. Fix: add `~` to both guards (`{^[/\\~]|^[a-zA-Z]+:|(?:^|[/\\])\.\.}`), or return to an allowlist that also admits digits and `+`, e.g. `^[A-Za-z0-9_+-]+(?:/[A-Za-z0-9_+-]+)*$`. Sharing one helper with `msgcat::UnsafeLocale` would keep the two checks from drifting apart again. A safe-interp test along the lines of msgcat-1.15 (HOME set to a temp dir) would cover it. - foundin changed to:
8.6.16, 8.6.17, 8.6.18 (core-8-6-branch as of 2026-11-03)
- is_private changed to: "0"
- login: "bef"
- priority changed to: "5 Medium"
- private_contact changed to: "37918056d323dc69a2f76cecc85476189094f3b8"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "bef"
- subsystem changed to: "16. Commands A-H"
- title changed to:
`clock -timezone` escapes safe interp via `~` path (8.6.16+, same gap as [2f8bb48009])
- type changed to: "Bug"