Skip to content

Commit a61cb54

Browse files
h4x3rotabclaude
andauthored
tsm-shim: make inblob/outblob usable by non-root apps
A non-root app (e.g. uid 1000) couldn't open the FIFOs: mkfifo used 0600, further cut by umask. chmod them after creation (configurable via TSM_REPORT_MODE, default 0666). Verified with an app as uid 1000 not in the root group. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 28927bc commit a61cb54

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

tsm-shim/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ phala cvms logs <app_id> -c app # expect PASS and a ~5 KB quote
5959
dstack doesn't expose).
6060
- One request at a time, one shim per app — a shared `inblob`/`outblob` can't tell
6161
concurrent callers apart. An empty `outblob` read means the quote failed.
62+
- `inblob`/`outblob` are created mode `0666`, so a non-root app can use them. Set
63+
`TSM_REPORT_MODE` (e.g. `0660`) on the `tsm-shim` service to restrict access.

tsm-shim/tsm_shim.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
# How long to wait for the app to open outblob for reading before giving up, so a
2929
# caller that writes inblob then dies can't wedge the daemon.
3030
OUTBLOB_DEADLINE = float(os.environ.get("TSM_OUTBLOB_DEADLINE", "30"))
31+
# Mode for inblob/outblob. Default 0666 so a non-root app (any uid) in the same
32+
# container can read/write them -- the shared volume is the access boundary, not
33+
# the file bits. Set e.g. 0660 to restrict to the file's group.
34+
REPORT_MODE = int(os.environ.get("TSM_REPORT_MODE", "0666"), 8)
3135

3236

3337
def log(msg):
@@ -88,7 +92,8 @@ def open_write_deadline(path, deadline=30.0):
8892
def make_fifo(path):
8993
if os.path.lexists(path):
9094
os.remove(path)
91-
os.mkfifo(path, 0o600)
95+
os.mkfifo(path)
96+
os.chmod(path, REPORT_MODE) # chmod, not the mkfifo arg: the latter is cut by umask
9297

9398

9499
def main():

0 commit comments

Comments
 (0)