Back to skill

Security audit

Cn Id Validator

Security checks for vulnerabilities and agentic risk

Overview

This local validator does not appear to steal data, but it handles sensitive Chinese ID numbers and has privacy and validation issues that could mislead real verification workflows.

Use this only as a local reference utility unless it is hardened. Do not submit or log real ID numbers unless you have a lawful need and consent, mask raw IDs where possible, retain them minimally, and do not rely on this script as the sole identity or age-verification control until numeric and region validation are fixed.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/id_validator.py:19
Finding

Malformed 15-Digit Identity Numbers Accepted Due to Incomplete Character Validation

Content
View full analysis

Vulnerability Details

File Location: scripts/id_validator.py, lines 19–27
Vulnerability Type: Incomplete input validation
Risk Level: Medium

python
def validate_id15(id15):
    if len(id15) != 15:
        return False
    try:
        from datetime import datetime
        y, m, d = int("19" + id15[6:8]), int(id15[8:10]), int(id15[10:12])
        datetime(y, m, d)
        return True
    except:
        return False

Technical Analysis

The validator only checks that the input contains exactly 15 characters and that characters at positions 7–12 represent a valid date. It does not require the entire identifier to consist of digits. Consequently, the region and sequence fields may contain arbitrary nonnumeric characters.

For example, ABCDEF900307AA1 contains 15 characters, a valid encoded date (1990-03-07), and a numeric final gender digit. It therefore passes validate_id15() despite not being a valid 15-digit Chinese identity number.

The implementation also returns the first six characters as a region without validating their numeric format or checking them against administrative region codes. This conflicts with the documented validation rules that identity numbers must contain digits and that region codes are valid.

Attack Path

  1. An application uses this utility to validate identity numbers during registration, age verification, or another business process.
  2. An attacker constructs a 15-character value with:
    • Arbitrary characters in the six-character region field.
    • A valid date in positions 7–12.
    • Arbitrary characters in the first two sequence positions.
    • A numeric character in the final position.
  3. The attacker submits a value such as ABCDEF900307AA1.
  4. The length check succeeds.
  5. The date fields decode to the valid date 1990-03-07.
  6. validate_id15() returns True, and parse_id() produces trusted-looking region, birthday, and ge ...[truncated 684 chars]
Remediation
View remediation

Remediation Suggestions

Require all 15 characters to be ASCII decimal digits before parsing individual fields:

python
def validate_id15(id15):
    if len(id15) != 15 or not id15.isascii() or not id15.isdigit():
        return False

    try:
        from datetime import datetime

        year = int("19" + id15[6:8])
        month = int(id15[8:10])
        day = int(id15[10:12])
        datetime(year, month, day)
    except (TypeError, ValueError):
        return False

    return validate_region_code(id15[:6])

Additional hardening should include:

  • Validate the first six characters against a maintained, authoritative administrative-region dataset when region validity is claimed.
  • Use explicit exception types such as TypeError and ValueError instead of a bare except.
  • Apply equivalent explicit character validation to the 18-character format, allowing digits in the first 17 positions and only a digit or X in the checksum position.
  • Add negative tests for alphabetic region fields, alphabetic sequence fields, Unicode numeric characters, invalid dates, and unknown region codes.
  • Clearly document whether validation covers only syntax and checksum rules or also verifies current administrative-region assignments.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (2)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This skill processes highly sensitive national identity numbers and explicitly supports extracting birth date, gender, and region, but it does not present a clear privacy warning, data-handling limitation, or guidance to avoid storing or exposing this data. That omission increases the risk of unsafe use, over-collection, accidental logging, or downstream misuse of regulated personal data in registration, verification, or analytics workflows.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The code returns gender values as the Chinese strings "男" and "女" unconditionally. This is a natural-language locale choice embedded in the skill output, with no option for the user to select another language or a documented justification for restricting output to Chinese labels.

Content

No source excerpt is available for this finding.