T09 · Insecure Skill Coding Practices
- Location
execution/deadline_tracker.py:145- Finding
Confidential Legal Matter Data Stored Without Encryption or Enforced File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
execution/deadline_tracker.py:20-23, 145-184;templates/config.yaml:116-120
Vulnerability Type: Plaintext storage of sensitive legal matter data with insufficient permission enforcement
Risk Level: MediumVulnerable Code
python # execution/deadline_tracker.py:20-23 DEFAULT_DB_PATH = os.environ.get( "LEGALDOC_DEADLINES_DB", os.path.expanduser("~/.legaldoc/deadlines.db") )python # execution/deadline_tracker.py:145-184 class DeadlineDatabase: """SQLite-based deadline storage.""" def __init__(self, db_path: str = DEFAULT_DB_PATH): self.db_path = db_path Path(db_path).parent.mkdir(parents=True, exist_ok=True) self._init_db() def _init_db(self): """Initialize database schema.""" conn = sqlite3.connect(self.db_path) cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS deadlines ( id TEXT PRIMARY KEY, description TEXT NOT NULL, date TEXT NOT NULL, category TEXT NOT NULL, matter_id TEXT, matter_name TEXT, court TEXT, case_number TEXT, notes TEXT, alert_days TEXT, completed INTEGER DEFAULT 0, completed_at TEXT, created_at TEXT, source_document TEXT ) """) cursor.execute(""" CREATE INDEX IF NOT EXISTS idx_deadline_date ON deadlines(date) """) cursor.execute(""" CREATE INDEX IF NOT EXISTS idx_deadline_matter ON deadlines(matter_id) """) conn.commit() conn.close()yaml # templates/config.yaml:116-120 security: encrypt_at_rest: false delete_after_processing: false anonymize_logs: true allowed_ip_ranges: ...[truncated 2351 chars]- Remediation
View remediation
Remediation Suggestions
-
Enforce restrictive filesystem permissions
- Create
~/.legaldocwith mode0700. - Create the database with mode
0600. - Validate and correct permissions on existing directories and database files.
- Reject database paths that resolve to unsafe shared or world-writable locations unless the user explicitly overrides the warning.
- Create
-
Encrypt sensitive data at rest
- Use an appropriately reviewed encrypted database mechanism or encrypt sensitive columns before insertion.
- Store encryption keys in an operating-system credential store or dedicated secrets manager rather than beside the database.
- Define key rotation, recovery, and revocation procedures.
-
Minimize persisted information
- Avoid storing document-context excerpts as deadline descriptions unless required.
- Store opaque matter identifiers instead of matter names where possible.
- Make persistence of notes, case numbers, and source-document names optional.
- Apply configurable retention and secure deletion policies.
-
Improve disclosure and configuration
- Clearly document that deadline records are persisted locally.
- Do not present encryption at rest or privilege protection as enabled when
encrypt_at_restis false. - Warn users that custom paths and backups may expose confidential information.
-
Add security tests
- Verify directory and database modes after first use.
- Test behavior under permissive umasks.
- Test migration and permission correction for existing installations.
- Confirm that sensitive fields are unreadable without the encryption key.
-
