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 method builds query predicates from caller-supplied filter keys using getattr(self.__model__, key) without validating that the key is an allowed column. While SQLAlchemy prevents classic SQL injection here, untrusted callers can still trigger access to unintended model attributes, cause exceptions for invalid keys, and potentially bypass intended query restrictions if this generic DAO is exposed through higher-level interfaces.
