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
- 82% confidence
- Finding
- This code uses user-supplied filter keys to dynamically select model attributes via getattr(self.__model__, key) with no allowlist or existence check. While this is not classic SQL injection because SQLAlchemy still parameterizes values, it can let callers query on unintended columns, trigger exceptions for bad attribute names, and expose or manipulate records based on sensitive/internal fields that should not be externally filterable.
