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
- 81% confidence
- Finding
- This code applies filter keys directly via getattr(self.__model__, key) using the caller-supplied filters dictionary. Although SQLAlchemy prevents classic SQL injection here, unvalidated attribute selection can let callers query on unintended columns, trigger exceptions for invalid attributes, and bypass business restrictions if higher layers pass user-controlled filter keys.
