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
- 80% confidence
- Finding
- This code uses unvalidated keys from the filters dict to dynamically access model attributes. While SQLAlchemy prevents classic SQL injection here, an attacker who can control filter keys may trigger access to unintended model attributes, cause exceptions for invalid names, or bypass intended query restrictions by querying on sensitive fields the caller should not control.
