Dynamic attribute access via getattr()
Low
- Category
- Dangerous Code Execution
- Content
if filters: for key, value in filters.items(): query = query.filter(getattr(self.__model__, key) == value) if offset: query = query.offset(offset)- Confidence
- 74% confidence
- Finding
- Here getattr(self.__model__, key) uses keys from the caller-supplied filters dict, so an attacker controlling filter names can access unintended mapped attributes and influence query construction. While SQLAlchemy prevents classic SQL injection here, this pattern enables unvalidated field selection and can expose or query on columns the caller should not control, which is risky in a generic persistence layer.
