Skip to content

worker, helper: keep operation arguments off process argv - #17

Draft
ash-iir wants to merge 1 commit into
mainfrom
fix-secrets-argv
Draft

ash-iir wants to merge 1 commit into
mainfrom
fix-secrets-argv

Conversation

@ash-iir

@ash-iir ash-iir commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Long operations received their base64 JSON arguments (passphrases included) on the worker's argv for the whole run. Under mksh, printf is not a builtin, so printf '%s' "$X" | … also runs an external command with the data in its arguments.

  • detach() (helper.sh) writes the args to $STATE/staging/args.<opid> with umask 077, via a here-doc into cat, and starts the worker with only <verb> <opid>.
  • worker.sh reads that file once (base64 -d <file) and removes it right away; cleanup already removes any *<opid>* staging leftovers.
  • jget feeds jq from a here-doc instead of printf.
  • enc_age/dec_age feed the passphrase to script/age from a here-doc instead of printf.

helper.sh already uses here-docs at runtime, so they work under the shells the module runs in.

Not in this PR:

  • The Telegram 2FA password is still passed to mtproto-store sign-in --password; the binary only takes it as a flag, so that needs a change in mtproto-store first (an env var or stdin).
  • The WebUI still calls sh helper.sh <verb> <b64>; that process is short-lived for detached verbs, but synchronous verbs keep it for their run.

Testing

  • sh -n, mksh -n, busybox sh -n on both scripts; shellcheck -s sh: same warnings as upstream main (96 worker, 58 helper).
  • Under mksh R59, busybox 1.37 ash and dash: the real detach, jget, enc_age, dec_age functions with a stub worker and a stub script: worker argv is only <verb> <opid>, args round-trip byte-exact (passphrase with \, quotes, $(...), backticks, -n), the file is 0600 and removed after reading, a bad opid is still refused, and the stub sees exactly pass\npass / pass on stdin.
  • Real age encryption/decryption was not run.
  • Not tested on a rooted device.

detach() now hands the worker its arguments in a 0600 file under the
root-only state dir instead of argv; the worker reads it once and removes
it. jget and the age passphrase feed use here-docs instead of printf,
which is not a builtin in mksh and would otherwise run as an external
command with the data in its arguments.

Signed-off-by: ash-iir <254348575+ash-iir@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant