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
- 78% confidence
- Finding
- Using getattr(self.__model__, key) with caller-supplied filter keys enables unvalidated dynamic column selection. Although SQLAlchemy prevents classic SQL injection here, an attacker who can control filters may query on unintended attributes, trigger exceptions for invalid names, or bypass intended business restrictions by filtering on sensitive/internal columns.
