Skip to content

Escape Script-Fu path literals to prevent injection#60

Merged
yuh-yang merged 1 commit intoHKUDS:mainfrom
Mirza-Samad-Ahmed-Baig:fix/gimp-script-fu-path-escape
Mar 14, 2026
Merged

Escape Script-Fu path literals to prevent injection#60
yuh-yang merged 1 commit intoHKUDS:mainfrom
Mirza-Samad-Ahmed-Baig:fix/gimp-script-fu-path-escape

Conversation

@Mirza-Samad-Ahmed-Baig
Copy link
Copy Markdown
Contributor

Summary

Fixes a critical security issue in the GIMP backend by preventing Script-Fu command injection through file paths.

What was wrong

input_path / output_path were interpolated directly into Script-Fu strings in gimp_backend.py.
A crafted path containing quotes or control characters could break out of the intended string and inject additional Script-Fu code.

What this PR changes

  • Adds _script_fu_escape() to safely escape values embedded in Script-Fu double-quoted strings.
  • Uses escaped path variants (safe_abs_input, safe_abs_output) in:
  • create_and_export()
  • apply_filter_and_export()
  • Keeps existing behavior unchanged for normal paths.

Jah-yee pushed a commit to Jah-yee/CLI-Anything that referenced this pull request Mar 13, 2026
Adds _script_fu_escape() to safely escape values embedded in
Script-Fu double-quoted strings. Prevents command injection through
crafted file paths containing quotes or control characters.

- Added _script_fu_escape() function for escaping backslashes, quotes,
  and control characters
- Updated create_and_export() to use safe path variants
- Updated apply_filter_and_export() to use safe path variants

Fixes: HKUDS#60
@yuh-yang yuh-yang merged commit 1e1870f into HKUDS:main Mar 14, 2026
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.

2 participants