mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4204] [CLOSED] [Other] Image generation: hand the prompt to sd-cli in an owner-only file, not on its command line #4947
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4947
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4204
Author: @schmittcn
Created: 10/26/2026
Status: ❌ Closed
Base:
main← Head:pr/image-prompt-file📝 Commits (1)
74edc6aImage generation: hand the prompt to sd-cli in an owner-only file (--prompt-file), not on its command line, where every local account can read it (ps, /proc//cmdline); the fake sd-cli reads it; test (#4202)📊 Changes
3 files changed (+39 additions, -12 deletions)
View changed files
📝
serve/fixtures/fake_sd_cli.py(+3 -1)📝
serve/images.py(+15 -4)📝
serve/test_images.py(+21 -7)📄 Description
Problem and result
With an
"images"section in the run config,serve/images.pystarted sd-cli with the request's prompt as a command-line argument (-p <prompt>). Every local account can read another process's arguments (ps,/proc/<pid>/cmdline) unless/procis mounted withhidepid, so on a PC with several accounts private image prompts were readable while an image was generated (#4202).Now the prompt goes to sd-cli as a file:
write_prompt()writes it toprompt.txtin the job's own folder (created bymkdtemp, 0700) with mode 0600, and sd-cli gets--prompt-file <path>. The file is removed with the job's other files when the job ends, as before.Related discussion
Fixes #4202. Found by a reviewer of a third-party Omarchy plugin that starts Strata models (omacom/omarchy-plugin-marketplace#12853).
Approach
--prompt-filecame to stable-diffusion.cpp in 854bebfe0 (leejet/stable-diffusion.cpp#1693, 2026-06-22). The only commit Strata has pinned,SD_CPP_COMMIT2988060 intools/image/qimage.py(sincea5b3b6c2), is 241 commits after it, so every sd-cli setup has built knows the flag. sd-cli reads the file as raw bytes into the prompt; it is written as UTF-8 without newline translation, so the prompt is unchanged.serve/fixtures/fake_sd_cli.pynow reads the prompt from--prompt-file, so the HTTP tests check that the prompt still arrives end to end.Validation
Passed:
python -m serve.test_images: 20 tests OK (onmain4b9e05a2: OK before the change too). The newtest_prompt_not_on_the_command_linechecks the file's content (multi-line, non-ASCII), its mode 0600 (not on Windows), that the prompt is not in the command and that--prompt-filenames the file.Not run:
examples/common/common.cpp(on_prompt_file_arg).os.open(..., 0o600)only sets the read-only bit there; the job folder's ACL is what protects it, as for the images themselves.Limits
Only the prompt moves off the command line. The other arguments (size, seed, steps, file paths) stay there; none of them carry user content.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.