security: Escape field values that might contain RPM macros#301
Open
gordonmessmer wants to merge 1 commit into
Open
security: Escape field values that might contain RPM macros#301gordonmessmer wants to merge 1 commit into
gordonmessmer wants to merge 1 commit into
Conversation
hroncok
approved these changes
Apr 21, 2026
Member
hroncok
left a comment
There was a problem hiding this comment.
Looks OK. I haven't tested it, and the CI here is dead
Addresses multiple security vulnerabilities where untrusted input could inject RPM macros and directives during spec file generation. Vulnerabilities fixed: 1. update_attr() bypass - set_from(..., update=True) bypassed __setattr__ escaping, allowing PyPI metadata to inject macros 2. Missing field escaping - dirname, sphinx_dir, scripts, py_modules, packages, doc_files, doc_license were rendered without escaping 3. Dependency injection - package names in dependencies not escaped 4. Truncate/wordwrap boundary - could split %% leaving dangerous single % Solution: - Removed bypassable __setattr__ escaping from package_data.py - Implemented render-time escaping with new rpm_escape Jinja filter - Applied escaping at correct points in filter chain: * Before replace() operations to preserve template macros * Inside module_to_path/package_to_path filters for literal returns * Before name_for_python_version for dependency names * After truncate/wordwrap for descriptions - Updated all 6 template variants (fedora, epel6, epel7, mageia, pld, macros) - Updated test expectations to reflect escaped output - Added comprehensive security test suite (294 lines) - Fixed tox.ini to use pytest directly instead of deprecated setup.py test All user-controlled fields now properly escaped while preserving legitimate RPM template macros. This flaw was reported by https://github.com/gouldnicholas Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Gordon Messmer <gmessmer@redhat.com>
Member
Author
|
@gouldnicholas please review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-by: Claude