Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-03
11:05 • New ticket [3d978e0a84] `clock -timezone` escapes safe interp via `~` path (8.6.... artifact: 0e8fecddd5 user: bef
2026-10-29
08:28 • Ticket [2f8bb48009] `clock -locale` escapes safe interp via `~` path (msgcat 1.6... artifact: 3c9b67c59d user: jan.nijtmans
08:25 • Closed ticket [2f8bb48009]. artifact: 594bcbb902 user: jan.nijtmans
08:17
Fix [2f8bb4]: msgcat did not check the locales check-in: d89487325d user: jan.nijtmans tags: core-8-6-branch
08:00
Fix [2f8bb4]: msgcat did not check the locales check-in: 15da8b971e user: jan.nijtmans tags: core-9-0-branch
08:00
Fix [2f8bb4]: msgcat did not check the locales check-in: 85a543ddd2 user: jan.nijtmans tags: trunk, main
2026-10-23
07:38 • Ticket [2f8bb48009] `clock -locale` escapes safe interp via `~` path (msgcat 1.6... artifact: e2d6dedbd0 user: serhiy.storchaka
07:37
Fix [2f8bb48009] for 8.6: [clock -locale ~/...] in a safe interp made the parent source a catalog fi... closed check-in: d0b624839d user: serhiy.storchaka tags: msgcat-unsafe-locale-8-6
07:24 • Ticket [2f8bb48009] `clock -locale` escapes safe interp via `~` path (msgcat 1.6... artifact: b14addeb2d user: serhiy.storchaka
07:23
Fix [2f8bb48009]: msgcat did not check the locales passed to [mcpackagelocale preferences], and did ... closed check-in: 6e51715b5c user: serhiy.storchaka tags: msgcat-unsafe-locale
2026-10-20
21:17 • Ticket [2f8bb48009] `clock -locale` escapes safe interp via `~` path (msgcat 1.6... artifact: b4d592f930 user: jan.nijtmans
18:16 • New ticket [2f8bb48009]. artifact: 5fdea9ff55 user: bef

`clock -locale` escapes safe interp via `~` path (msgcat 1.6.2/1.7.2)

Closed / Fixed2f8bb4800932dd6fa42197835d039ba21209013cCreated 43 days agoUpdated 35 days ago
Descriptionmarkdown2026-10-20 18:16:26

The locale path check added in msgcat 1.6.2 / 1.7.2 (regexp {^[/\\]|^[a-z]+:|(?:^|[/\\])\.\.}, from ticket 301613) does not reject a leading ~. [clock] is aliased into safe interpreters and runs in the parent, and msgcat::Load does file join $langdir $locale.msg then source. On 8.6, file join tilde-expands, so a safe child can make the trusted parent source any .msg file reachable through ~/~user — a full sandbox escape (arbitrary code in the parent). mclocale and clock's -timezone guard both reject such values; the -locale → mcpackagelocale path is weaker.

PoC (Tcl 8.6 with msgcat 1.6.2):

file mkdir ~/tcldemo
set fd [open ~/tcldemo/x.msg w]
puts $fd {puts "PWNED issafe=[interp issafe] exec=[info commands exec]"}
close $fd

interp eval [interp create -safe] {clock format 0 -gmt 1 -locale ~/tcldemo/x}

file delete ~/tcldemo/x.msg

Output:

PWNED issafe=0 exec=exec

i.e. x.msg ran in the trusted parent (issafe=0, exec present), from a one-line call inside a safe child. 9.x is not escapable this way (there file join leaves a leading ~ literal), but it is still affected by the related bypass below.

Fix: also reject a leading ~ (or reuse mclocale's $v eq [file tail $v] test). A related gap on 9.x (msgcat 1.7.2): mcpackagelocale preferences <locale> sets the preference list straight from its args and calls Load without going through getpreferences, so the new regexp never runs and even an absolute path still loads — e.g. mcpackagelocale preferences /abs/x sources /abs/x.msg where mcpackagelocale set /abs/x is correctly rejected. (On 8.6 preferences is read-only, so that route is 9.x-only.) Validating centrally in msgcat::Load would cover every route at once.

Referenced by3
  • 0e8fecddd5New ticket [3d978e0a84] `clock -timezone` escapes safe interp via `~` path (8.6.16+, same gap as [2f8bb48009]). ticket2026-11-03 11:05:41
  • d0b624839dFix [2f8bb48009] for 8.6: [clock -locale ~/...] in a safe interp made the parent source a catalog file from a home directory, since msgcat did not reject a leading "~" and [file join] expands it. Check every locale with the same test, also in msgcat::Load before a catalog file is sourced. Tests msgcat-1.14, 1.15 and more cases of msgcat-12.11. check-in2026-10-23 07:37:54
  • 6e51715b5cFix [2f8bb48009]: msgcat did not check the locales passed to [mcpackagelocale preferences], and did not reject a leading "~". Check every locale with the same test, also in msgcat::Load before a catalog file is sourced. Tests msgcat-12.13 to 12.15. check-in2026-10-23 07:23:05
jan.nijtmanswiki2026-10-20 21:17:15

@sebres, this one is for you, since it's related to [this] commit

serhiy.storchakawiki2026-10-23 07:24:03

Confirmed. On main and 9.0, mcpackagelocale preferences loads its arguments without the locale check, so an absolute path is sourced; on 8.6 the leading ~ route works as described.

Proposed fix in branch msgcat-unsafe-locale (for main and 9.0): one check for all routes, which also rejects a leading ~, applied in getpreferences, to every argument of mcpackagelocale preferences, and in msgcat::Load before a catalog file is sourced, as suggested. Tests msgcat-12.13 to 12.15. 8.6 needs a separate change, since preferences is read-only there. The msgcat version is not bumped.

serhiy.storchakawiki2026-10-23 07:38:26

Proposed fix for 8.6 in branch msgcat-unsafe-locale-8-6: the same check, which rejects a leading ~, in mclocale, mcpackagelocale set and msgcat::Load. Test msgcat-1.15 runs the example from this ticket in a safe interp, with HOME set to the temporary directory.

jan.nijtmanswiki2026-10-29 08:25:43

Fixed in [trunk], core-9-0-branch and core-8-6-branch

Many thanks!

jan.nijtmanswiki2026-10-29 08:28:52

> The msgcat version is not bumped

There's no need to bump the msgcat version, because msgcat 1.6.2/1.7.2 were never released in a public Tcl release.

Log in (anonymous is fine) to add a comment.