T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:205- Finding
Unbounded Calibration Interval Allows Persistent Schedule Corruption and Denial of Service
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py:105,scripts/main.py:151, andscripts/main.py:205-223
Vulnerability Type: Improper input validation and numeric range validation
Risk Level: MediumVulnerable Code
python next_cal = last_cal + timedelta(days=data["interval_months"] * 30)python next_cal = last_cal + timedelta(days=data["interval_months"] * 30)python parser.add_argument("--interval", type=int, help="Calibration interval (months)") args = parser.parse_args() log = EquipmentLog() if args.add: if not args.calibration_date: print("Error: --calibration-date is required when using --add") sys.exit(1) if not args.interval: print("Error: --interval is required when using --add") sys.exit(1) log.add(args.add, args.calibration_date, args.interval, args.location or "") elif args.update: log.update(args.update, args.calibration_date, args.interval, args.location)Technical Analysis
The
--intervalargument is converted to an integer but is not validated against an acceptable numeric range. The conditionif not args.intervalrejects only a missing value and zero. It permits negative integers and arbitrarily large positive integers.The update path passes the supplied interval directly to
EquipmentLog.update()without any positivity or upper-bound check. Both add and update operations therefore allow an invalid value to be persisted in~/.openclaw/equipment_log.json.Subsequent
--checkand--reportoperations multiply the stored interval by 30 and pass it totimedelta. A negative interval produces a maintenance due date before the calibration date and corrupts compliance results. A sufficiently large integer can cause anOverflowErrorwhen constructing thetimedeltaor adding it to the stored date, terminating the operation. Because the invalid value is persisted, later checks and reports continue to fail until the affected ...[truncated 1658 chars]- Remediation
View remediation
Remediation Suggestions
Enforce a bounded positive interval at every trust boundary:
- Reject values outside a documented operational range, such as 1 through 120 months, during both add and update operations.
- Use a dedicated
argparsetype validator so invalid values are rejected before application logic runs. - Repeat validation inside
EquipmentLog.add()andEquipmentLog.update()so callers cannot bypass CLI validation. - Validate the type and range of every interval loaded from the JSON file because the file may be corrupted or manually modified.
- Catch
OverflowError,TypeError, andKeyErrorduring date calculations. Skip the malformed record with a clear warning rather than terminating the entire report. - Write updates atomically only after the complete record has passed validation.
Example validator:
python def positive_interval(value): try: interval = int(value) except ValueError: raise argparse.ArgumentTypeError("Interval must be an integer.") if not 1 <= interval <= 120: raise argparse.ArgumentTypeError( "Interval must be between 1 and 120 months." ) return interval parser.add_argument( "--interval", type=positive_interval, help="Calibration interval in months (1-120)" )Apply equivalent validation before storing or consuming loaded records.
