T09 · Insecure Skill Coding Practices
- Location
SKILL.md:115- Finding
Image Analysis APIs Return Fabricated Results Without Inspecting Input Images
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:115-147,SKILL.md:221-243,SKILL.md:286-305,SKILL.md:330-352
Vulnerability Type: Deterministic fabricated image-analysis and safety results
Risk Level: HighVulnerable Code
Simulated OCR results (
SKILL.md:115-147)python def extract_text( self, image_data: bytes, language: str = "en" ) -> List[TextRegion]: """Extract text from image""" # Simulated OCR extraction (use actual OCR library in production) # In production: pytesseract, EasyOCR, or cloud OCR services regions = [] # Simulate detecting title block in drawing regions.append(TextRegion( text="PROJECT: OFFICE BUILDING", bbox=BoundingBox(x=100, y=50, width=300, height=30, confidence=0.95), confidence=0.95, language=language )) regions.append(TextRegion( text="DRAWING: A-101", bbox=BoundingBox(x=100, y=90, width=200, height=25, confidence=0.92), confidence=0.92, language=language )) regions.append(TextRegion( text="SCALE: 1:100", bbox=BoundingBox(x=100, y=120, width=150, height=20, confidence=0.88), confidence=0.88, language=language )) return regionsSimulated object and PPE detections (
SKILL.md:221-243)python def detect( self, image_data: bytes, confidence_threshold: float = 0.5 ) -> List[DetectedObject]: """Detect objects in image""" # Simulated detection (use actual model in production) # In production: YOLO, Faster R-CNN, etc. detected = [] # Simulate detected objects sample_detections = [ ("worker", 0.92, BoundingBox(200, 300, 80, 180, 0.92)), ("hard_hat", 0.88, BoundingBox(210, 300, 30, 25, 0.88)), ("safety_vest", 0.85, BoundingBox(210, 340, 60, 80, 0.85)), ("scaffolding", 0.78, BoundingBox(400, 100, 200, 400, 0.78)), ("concrete_block", 0.72, BoundingBox(50, 450, 1 ...[truncated 4690 chars]- Remediation
View remediation
Remediation Suggestions
- Replace every simulated routine with an actual validated OCR, object-detection, table-extraction, or image-segmentation implementation before production use.
- If the implementation is intended only as an example, move it into clearly identified test or example code and prevent it from being exposed as a functional production API.
- Introduce an explicit mock-mode setting that is disabled by default. Synthetic results must include an unmistakable marker such as
"synthetic": trueand must never be represented as observations. - In the absence of a configured analysis backend, fail closed with a clear error such as
NotImplementedErrorrather than returning fabricated data. - Validate that image input is non-empty, decodable, within supported size limits, and in an allowed format before analysis.
- Derive confidence scores exclusively from the configured analysis backend. Do not hardcode values that imply evidentiary certainty.
- Treat safety and progress conclusions as advisory. Include model version, processing provenance, uncertainty, and manual-review requirements in each result.
- Add automated tests proving that:
- blank and corrupted images are rejected;
- materially different images do not produce identical findings;
- PPE compliance cannot be reported without image-derived worker and PPE associations;
- progress measurements require valid visual evidence;
- simulated data cannot be emitted when production mode is enabled.
- Require human verification before safety findings or progress estimates are used for compliance, reporting, or operational decisions.
