|
2026-11-04
| ||
| 08:59 | • Ticket [3d978e0a84] `clock -timezone` escapes safe interp via `~` path (8.6.16+,... artifact: b4693c4f5c user: bef | |
|
2026-11-03
| ||
| 15:58 | • Closed ticket [3d978e0a84]. artifact: 0adf0466a5 user: jan.nijtmans | |
| 15:56 | Fix [3d978e0a84]: 'clock -timezone' escapes safe interp check-in: ee4f07c809 user: jan.nijtmans tags: core-8-6-branch | |
| 14:21 | • Ticket [3d978e0a84] `clock -timezone` escapes safe interp via `~` path (8.6.16+,... artifact: 0ee44b0692 user: serhiy.storchaka | |
| 14:18 | Fix [3d978e0a84]: [clock -timezone ~/...] in a safe interp made the parent source a file from a home... closed check-in: f4176f1e45 user: serhiy.storchaka tags: clock-unsafe-timezone-8-6 | |
| 11:05 | • New ticket [3d978e0a84] `clock -timezone` escapes safe interp via `~` path (8.6.... artifact: 0e8fecddd5 user: bef | |
`clock -timezone` escapes safe interp via `~` path (8.6.16+, same gap as [2f8bb48009])
Follow-up to 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):
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 (fix for
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.
ee4f07c809Fix [3d978e0a84]: 'clock -timezone' escapes safe interp check-in2026-11-03 15:56:32f4176f1e45Fix [3d978e0a84]: [clock -timezone ~/...] in a safe interp made the parent source a file from a home directory, since the time zone path check did not reject a leading "~" (regression in 8.6.16). Reject it in LoadTimeZoneFile and LoadZoneinfoFile, and add tests. check-in2026-11-03 14:18:23
Reproduced on core-8-6-branch and 8.6.16, not on 8.6.15.
Proposed fix in branch 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.
Fixed in [core-8-6-branch]
Many thanks!
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