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
- 79% confidence
- Finding
- This code applies filters using getattr(self.__model__, key) where key comes from the caller-provided filters dictionary. Although SQLAlchemy prevents classic SQL injection here, unvalidated attribute selection can let callers query on unintended columns, bypass business restrictions, or trigger exceptions for bad attributes, which becomes risky in a generic DAO reused across skills.
