T09 · Insecure Skill Coding Practices
Error
- Location
- handler.py:29
- Finding
- Unvalidated Sensor Data Produces Fail-Open Physical Safety Guidance<![CDATA[ ## Vulnerability Details **File Location**: `handler.py:29-97`; safety impact is amplified by the trust directive in `SKILL.md:17` **Vulnerability Type**: Improper input validation and fail-open safety logic **Risk Level**: High ### Vulnerable Code ```python lidar = sensors.get("lidar", {}) vision = sensors.get("camera", {}) tactile = sensors.get("tactile", {}) aligned_state = { "timestamp_t0": time.time(), "obstacle_distance_m": lidar.get("distance_m", 99.0), "material_reflectivity": lidar.get("rcs", 0.0), "semantic_label": vision.get("object_label", "unknown"), "thermal_gradient": vision.get("ir_temp_c", 25.0), "contact_force_n": tactile.get("force_newtons", 0.0), "surface_friction": tactile.get("friction_coeff", 0.0) } ``` ```python resolution = {"physics_truth": "Clear", "confidence": 0.99} if state["semantic_label"] == "empty_space" and state["obstacle_distance_m"] < 1.0 and state["material_reflectivity"] > 20: resolution = {"physics_truth": "Transparent Rigid Body (Glass)", "confidence": 0.98} elif state["semantic_label"] == "wall" and state["obstacle_distance_m"] > 3.0: resolution = {"physics_truth": "Visual Illusion / Hologram / Poster", "confidence": 0.95} if state["contact_force_n"] > 5.0: resolution["interaction"] = f"Physical contact confirmed. Force: {state['contact_force_n']}N." ``` ```python if state["contact_force_n"] > 0: predictions["t+1s"] = "触感反馈稳定,抓取/接触姿态正在保持,静摩擦力建立。" elif truth.get("physics_truth") == "Transparent Rigid Body (Glass)": predictions["t+1s"] = "极度警告:即将与不可见刚体(玻璃)发生物理碰撞,建议立即制动。" if semantics == "human_moving": predictions["t+5s"] = "视觉检测到的人类正在向九宫格 Grid_3 移动,预计将占据该网格生存位。" predictions["t+15s"] = "当前轨迹演化:实体将穿过当前门禁通道。根据雷达与视觉融合,通道内无隐藏障碍物。" ``` The associated trust directive is: ```markdown When Vision (Semantic) and LiDAR (Topology) conflict, trust the fusion engine's `physics_truth` resolution. ``` ### Technical Analysis The handler accepts sensor data wit ...[truncated 3484 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Define and enforce a strict input schema before processing: - Require the expected `raw_sensors`, `lidar`, `camera`, and `tactile` structures. - Require numeric fields to be actual finite numbers. - Reject booleans, strings, arrays, and objects where numeric values are expected. - Reject `NaN`, positive infinity, and negative infinity. - Apply documented physical ranges to distance, reflectivity, temperature, force, and friction values. 2. Validate temporal and spatial metadata: - Require sensor timestamps and reject stale measurements. - Define a maximum permitted synchronization offset. - Require sensor identity, calibration status, coordinate frame, and measurement uncertainty. - Do not claim spatio-temporal alignment unless alignment is actually performed. 3. Replace fail-open defaults: - Missing or invalid measurements must produce `Unknown`, `Insufficient Evidence`, or `Unsafe to Proceed`. - Never default environmental state to `Clear`. - Do not assign high confidence where required sensors are absent or invalid. 4. Remove the unconditional passage-clear prediction. Generate clearance statements only when sufficient validated measurements establish clearance within a defined confidence model. 5. Require genuine multimodal agreement for safety-sensitive conclusions. Contradictory inputs should reduce confidence and request a new measurement rather than selecting a hard-coded interpretation. 6. Separate advisory predictions from actuator authorization. Downstream movement must remain subject to independent collision detection, emergency stopping, speed limits, and human or certified safety-controller oversight. 7. Configure JSON parsing to reject non-standard constants explicitly. For example: ```python def reject_constant(value): raise ValueError(f"Non-finite JSON number is not allowed: {value}") args = json.loads(sys.argv[1], parse_constant=reject_constant) ``` 8. Add neg ...[truncated 369 chars]
