Overview
| Artifact ID: | a3963ccbe82fe604431dad5dcf3951c458d32887900b5456577bd782cc35ad14 |
|---|---|
| Ticket: | f2ff05fc8411be80a93913b2b065f2c85fa9bcf0
Usage of static systemEncoding is not thread safe (vulnerability) |
| User & Date: | sebres on 2021-04-06 16:14:12 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
<code>Tcl_UtfToExternal*</code>, <code>Tcl_ExternalToUtf*</code> (et al.) have a certain weakness if used with NULL (system-encoding). If for some reason systemEncoding is a single reference (used only once), it will be used in that functions without to touch its refCount, so if another thread sets it to different value - it could segfault inside conversion if this previous system encoding gets freed. I know that normally the change of system encoding is either rare case, but a vulnerability remains vulnerability... Atomic incr/decr of its refCount may help here... But currently (without to have such atomic facilities) it would imply to use mutex, and it would be ugly by each conversion (would provide a multi-threaded bottleneck, even twice by start and end of convert-routines). As for atomic facilities, I made some for another issue - for example see [https://github.com/sebres/tcl/blob/1e522ffa06a7aca2fd729e709ffdccb4f56b6882/generic/tclInt.h#L131|sebres/tcl/1e522ff/tclInt.h#L131]. Simplest scenario to reproduce the SF (for understanding): <code><pre style="margin-left:15pt"> Tcl_SetSystemEncoding(NULL, "enc1"); ... thread::create { encoding convertfrom [string repeat "..." $Some_Large_N] }; Tcl_SetSystemEncoding(NULL, "enc2"); // BOOM in helper thread (if 2nd set takes place during convertfrom process and "enc1" is unused elsewhere)... </pre></code> - foundin changed to: "any"
- is_private changed to: "0"
- login: "sebres"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Critical"
- status changed to: "Open"
- submitter changed to: "sebres"
- subsystem changed to: "11. Conversions from String"
- title changed to:
Usage of static systemEncoding is not thread safe (vulnerability)
- type changed to: "Bug"