Skip to content

Validate attrs init aliases before code generation#1555

Open
uwezkhan wants to merge 3 commits into
python-attrs:mainfrom
uwezkhan:fix/validate-init-aliases
Open

Validate attrs init aliases before code generation#1555
uwezkhan wants to merge 3 commits into
python-attrs:mainfrom
uwezkhan:fix/validate-init-aliases

Conversation

@uwezkhan
Copy link
Copy Markdown

This PR fixes a code generation security issue where explicit field aliases were interpolated into generated init source without validation. A malicious alias such as a default parameter expression could execute code during class creation. The change validates initialization aliases before method generation, ensuring aliases are strings, valid Python identifiers, and not Python keywords. It also adds regression coverage proving invalid aliases are rejected and a malicious payload is not executed.

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