Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[Bug] SecurityValidator USER patterns path incorrect - points to nonexistent directory

Open Alt-168 opened this issue 10 months ago • 2 comments

Summary

The SecurityValidator hook references an incorrect path for USER pattern customizations. Line 182 points to ~/.claude/USER/PAISECURITYSYSTEM/patterns.yaml, but the actual USER directory is at ~/.claude/skills/CORE/USER/ per INSTALL.md.

(Notice skills/CORE/ directory omission in path)

Environment

  • PAI Version: v2.4 (fresh install)
  • OS: Ubuntu 22.04 LTS
  • Installation method: Full Release Install

Steps to Reproduce

  1. Fresh install of PAI v2.4
  2. Check SecurityValidator.hook.ts line 182 — expects ~/.claude/USER/PAISECURITYSYSTEM/patterns.yaml (note skills/CORE/ is missing from path)
  3. Check actual USER directory location — ~/.claude/skills/CORE/USER/
  4. The path in the code doesn't match the project's directory structure

Expected Behavior

SecurityValidator should look for USER patterns at ~/.claude/skills/CORE/USER/PAISECURITYSYSTEM/patterns.yaml, consistent with:

  • Where the USER directory actually exists
  • INSTALL.md which states: "Customize your identity — Edit $PAI_DIR/skills/CORE/USER/ files"
  • Parallel structure with SYSTEM patterns at ~/.claude/skills/CORE/SYSTEM/PAISECURITYSYSTEM/

Actual Behavior

  • USER directory exists at ~/.claude/skills/CORE/USER/
  • SYSTEM patterns are at ~/.claude/skills/CORE/SYSTEM/PAISECURITYSYSTEM/patterns.example.yaml
  • SecurityValidator incorrectly looks for USER patterns at ~/.claude/USER/ (line 182)
  • USER customization is unreachable

Documentation Inconsistency

INSTALL.md (https://github.com/danielmiessler/Personal_AI_Infrastructure/blob/main/INSTALL.md) correctly states:

"Customize your identity — Edit $PAI_DIR/skills/CORE/USER/ files"

pai-core-install README (https://github.com/danielmiessler/Personal_AI_Infrastructure/tree/main/Packs/pai-core-install) incorrectly shows:

Customization Location Impact
Security patterns USER/PAISECURITYSYSTEM/patterns.yaml Custom sensitive data detection

The pai-core-install README is missing the skills/CORE/ prefix, which matches the same error in the TypeScript file.

Additional Finding

Lines 188-204 show that if USER patterns exist, SYSTEM patterns are completely replaced (not merged). This means a user adding custom patterns would lose all default SYSTEM protections. This is not documented.

function getPatternsPath(): string | null {
  // Try USER patterns first (user's custom rules)
  if (existsSync(USER_PATTERNS_PATH)) {
    patternsSource = 'user';
    return USER_PATTERNS_PATH;      // <-- returns here, never checks SYSTEM
  }

  // Fall back to SYSTEM patterns (default template)
  if (existsSync(SYSTEM_PATTERNS_PATH)) {
    patternsSource = 'system';
    return SYSTEM_PATTERNS_PATH;
  }

  patternsSource = 'none';
  return null;
}

Relevant Code

SecurityValidator.hook.ts:

  • Line 182: const USER_PATTERNS_PATH = paiPath('USER', 'PAISECURITYSYSTEM', 'patterns.yaml');
  • Line 183: const SYSTEM_PATTERNS_PATH = paiPath('skills', 'CORE', 'SYSTEM', 'PAISECURITYSYSTEM', 'patterns.example.yaml');
  • Lines 188-204: getPatternsPath() returns early if USER exists, never loads SYSTEM

Suggested Fix

Issue 1: Incorrect path in SecurityValidator.hook.ts

File: ~/.claude/hooks/SecurityValidator.hook.ts

Before (line 182):

const USER_PATTERNS_PATH = paiPath('USER', 'PAISECURITYSYSTEM', 'patterns.yaml');

After (line 182):

const USER_PATTERNS_PATH = paiPath('skills', 'CORE', 'USER', 'PAISECURITYSYSTEM', 'patterns.yaml');

Issue 2: Ambiguous path in pai-core-install README

File: https://github.com/danielmiessler/Personal_AI_Infrastructure/tree/main/Packs/pai-core-install/README.md File: https://github.com/danielmiessler/Personal_AI_Infrastructure/tree/main/Packs/pai-core-install#optional-customization

Customization Location Impact
Security patterns USER/PAISECURITYSYSTEM/patterns.yaml Custom sensitive data detection

Issue 3: Replace vs merge behavior

Consider merging at load-time USER and SYSTEM patterns instead of replacing, so users can add custom patterns without losing default protections. This would require refactoring getPatternsPath() (lines 188-204) and loadPatterns() (lines 206-237) to load both files and merge the pattern arrays in memory.

Claude Code Prompt to Apply Fix for Issue 1 Only

Please fix the SecurityValidator hook path mismatch:

1. Open ~/.claude/hooks/SecurityValidator.hook.ts

2. Find line 182 which currently reads:
   const USER_PATTERNS_PATH = paiPath('USER', 'PAISECURITYSYSTEM', 'patterns.yaml');

3. Replace it with:
   const USER_PATTERNS_PATH = paiPath('skills', 'CORE', 'USER', 'PAISECURITYSYSTEM', 'patterns.yaml');

4. Save the file

5. Verify the fix by checking if the new path matches where USER actually exists:
   - List: ~/.claude/skills/CORE/USER/
   - Confirm PAISECURITYSYSTEM can be created there for customization

Report what you changed and confirm the path now aligns with the actual directory structure.

Alt-168 avatar Jan 29 '26 05:01 Alt-168

Thanks for reporting this! We've been doing a major restructuring of PAI's core systems, including a complete redesign of the hook architecture (consolidated from 22 to ~19 hooks), a rewritten Algorithm (now v0.5.1 with PRD-based verification), removal of the observability system, and numerous path/configuration fixes.

This specific issue is addressed by those changes. We're targeting a v3.0 release soon that will include all of this. We appreciate your patience and your help in identifying these issues — it directly informed our redesign work. Stay tuned!

danielmiessler avatar Feb 10 '26 21:02 danielmiessler

Thanks for reporting! The SecurityValidator was rewritten for v3.0 (now released) with corrected paths. Please upgrade to v3.0.

kaimagnus avatar Feb 15 '26 17:02 kaimagnus