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
- 76% confidence
- Finding
- The list() method applies filters using getattr(self.__model__, key) where key comes from the caller. Even though SQLAlchemy prevents classic SQL injection here, unvalidated attribute selection can let callers query on unintended fields, trigger exceptions for bad keys, and bypass intended access restrictions by filtering on sensitive/internal columns.
