T09 · Insecure Skill Coding Practices
- Location
engineering/engineering-ai-data-remediation-engineer.md:137- Finding
Unsafe Evaluation of AI-Generated Python Code
- Content
View full analysis
pd.DataFrame: """Apply AI-generated lambda across entire cluster — vectorized, not looped.""" if fix['confidence_score'] < 0.75: # Low confidence → quarantine, don't auto-fix df['validation_status'] = 'HUMAN_REVIEW' df['quarantine_reason'] = f"Low confidence: {fix['confidence_score']}" return df transform_fn = eval(fix['transformation']) # safe — evaluated only after strict validation gate (lambda-only, no imports/exec/os) df[column] = df[column].map(transform_fn) df['validation_status'] = 'AI_FIXED' df['ai_reasoning'] = fix['reasoning'] df['confidence_score'] = fix['confidence_score'] return df ``` ### Technical Analysis The documented implementation passes an LLM-generated string directly to Python's unrestricted `eval()`. The preceding validation is a substring blacklist rather than a security boundary. Requiring the value to begin with `lambda` does not make the expression safe. A lambda can invoke built-ins, mutate files, inspect Python objects, or perform other side effects. The blacklist blocks only five literal strings and can therefore be bypassed by functionality that does not contain those strings. For example, the following transformation satisfies the documented checks ...[truncated 1876 chars]- Remediation
View remediation
