Skip to content

Fix OS command injection via workflow OCR language settings (CWE-78) … - #393

Merged
R0Wi merged 1 commit into
stable33from
backport/33b830a464f5c777ada82bce013b7b7c692e1ef2-stable33
Aug 19, 2026
Merged

R0Wi merged 1 commit into
stable33from
backport/33b830a464f5c777ada82bce013b7b7c692e1ef2-stable33

Conversation

@R0Wi

@R0Wi R0Wi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Backport #391 to stable33

…391)

* Fix OS command injection via workflow OCR language settings (CWE-78)

WorkflowSettings.languages was validated with is_array() only. Its
elements were concatenated unescaped into the ocrmypdf command line
(CommandLineUtils::getCommandlineArgs), which is executed as a raw
shell string via mikehaertl/php-shellcommand's proc_open(). Unlike
customCliArgs, languages was never passed through the ';'/'&&'
stripping applied by escapeCustomCliArgs(), so any authenticated user
able to create a personal workflow (workflowengine API,
the web server user once a matching file was processed.

Fix, in two layers:
- WorkflowSettings now validates every language value against an
  allow-list pattern for tesseract/ocrmypdf language codes
  (letters/digits/underscore/slash, e.g. 'eng', 'chi_sim',
  'script/Latin'); an invalid array is rejected like any other
  malformed field, so a workflow with a malicious language value
  cannot be saved.
- CommandLineUtils applies the same allow-list again immediately
  before building the command line, filtering out and logging any
  value that doesn't match, as defense in depth for workflows stored
  before this fix.

Adds regression tests covering shell-metacharacter payloads
(';', '&&', '|', '$()', backticks) for both layers.

Reported by Duc Anh Nguyen (@gladiator9797).

* fix(ci): Remove autoload-dev from composer to get rid of OCP signature errors because of stale Nextcloud OCP composer package

---------

Co-authored-by: Claude <noreply@anthropic.com>
@R0Wi
R0Wi merged commit 8f5734f into stable33 Aug 19, 2026
13 checks passed
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