Artifacts Associated With Ticket 3d978e0a84738b5c
Ticket change [0e8fecddd5] (rid 261093) by bef on 2026-11-03 11:05:41:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized 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 initialized to:
8.6.16, 8.6.17, 8.6.18 (core-8-6-branch as of 2026-11-03)
- is_private initialized to: "0"
- login: "bef"
- priority initialized to: "5 Medium"
- private_contact initialized to: "37918056d323dc69a2f76cecc85476189094f3b8"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "bef"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
`clock -timezone` escapes safe interp via `~` path (8.6.16+, same gap as [2f8bb48009])
- type initialized to: "Bug"
Ticket change [0ee44b0692] (rid 261097) by serhiy.storchaka on 2026-11-03 14:21:30:
- icomment:
Reproduced on core-8-6-branch and 8.6.16, not on 8.6.15. Proposed fix in branch [/timeline?r=clock-unsafe-timezone-8-6|clock-unsafe-timezone-8-6]: both guards also reject a leading "~". Only a leading "~" matters: on 8.6 a "~" later in the path stays inside the data directory. 9.0 and later are not affected, since "~" is not expanded there, although adding "~" to the guards there would be harmless.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [0adf0466a5] (rid 261100) by jan.nijtmans on 2026-11-03 15:58:43:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2461348.1657848842"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed in [ee4f07c809|core-8-6-branch] Many thanks!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [b4693c4f5c] (rid 261105) by bef on 2026-11-04 08:59:45:
- closedate changed to: "2461348.8748320369"
- closer changed to: "bef"
- icomment:
Advisory write-up as I consider safe interp escape to be a security issue: [https://sektioneins.de/en/advisories/advisory-012026-tcl-clock-safe-interp-escape.html](https://sektioneins.de/en/advisories/advisory-012026-tcl-clock-safe-interp-escape.html)
- login: "bef"
- mimetype: "text/x-markdown"