Skip to content

KC-1504, KC-1519, KC-1526: Fix NSF ownership bypass and attacker-shared folder name collisions in mkdir, mv, ln, and record-add --folder - #2445

Open
sshrushanth-ks wants to merge 8 commits into
nsf-folder-path-resolution-fixfrom
nsf-folder-path-resolution-fix-int
Open

sshrushanth-ks wants to merge 8 commits into
nsf-folder-path-resolution-fixfrom
nsf-folder-path-resolution-fix-int

Conversation

@sshrushanth-ks

@sshrushanth-ks sshrushanth-ks commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  1. An attacker-owned or duplicate Nested Share Folder could be selected by name during folder creation, permission updates, shortcut operations, or record resolution. Added ownership-aware resolution, duplicate detection, and centralized fail-closed lookup across NSF and Secrets Manager commands.

  2. Duplicate classic folder paths could cause commands to select the first match or perform destructive actions against multiple folders. Extended ambiguity handling to rmdir and related folder operations. Duplicate classic, NSF, and Secrets Manager application titles now fail closed instead of selecting an arbitrary record.

  3. mkdir and nsf-mkdir now allow duplicate root-level folder names while requiring every parent path and child folder name to resolve uniquely. This prevents attacker-shared folder names from capturing mkdir, mv, ln, and record-add --folder operations while preserving valid duplicate root folders.

Changes

  • NSF resolution:

    • keepercommander/nested_share_folder/folder_api.py: Added ownership-aware NSF path resolution, safe folder_cache fallback checks, and duplicate folder rejection.
    • keepercommander/nested_share_folder/removal_api.py: Prefer owned records, reject ambiguous record titles, and centralize secure folder resolution.
    • keepercommander/commands/nested_share_folder/display_commands.py: Restrict nsf-get resolution to valid NSF folders and records.
    • keepercommander/commands/nested_share_folder/folder_commands.py: Preserve ownership metadata, allow duplicate NSF root folders, and require unique parent and child resolution for nsf-mkdir.
    • keepercommander/commands/nested_share_folder/sharing_commands.py: Remove the manual first-match folder fallback used by nsf-record-permission.
    • keepercommander/commands/nested_share_folder/record_commands.py: Route nsf-shortcut list and nsf-shortcut keep through duplicate-safe record resolution.
  • Classic folder and record resolution:

    • keepercommander/subfolder.py: Match folder names case-insensitively and reject ambiguous folder paths instead of selecting the first match.
    • keepercommander/commands/base.py: Make shared folder resolution fail closed on ambiguous paths.
    • keepercommander/commands/folder.py: Allow duplicate root folders in mkdir, require unique parent and child paths, and apply ambiguity handling to cd, mv, ln, rndir, and rmdir.
    • keepercommander/commands/record_edit.py: Reject record-add --folder when the folder is invalid or ambiguous.
  • Secrets Manager resolution:

    • keepercommander/commands/ksm.py: Remove first-match application title lookup and use duplicate-safe record resolution for classic and NSF applications.
  • Tests:

    • unit-tests/test_nested_share_folder.py: Add NSF ownership, path shadowing, duplicate root folder, duplicate parent folder, duplicate record, permission fallback, shortcut, and shared-in resolution tests.
    • unit-tests/test_subfolder.py: Add duplicate, case-variant, and ambiguous classic folder path tests.
    • unit-tests/test_command_record.py: Prevent unfiled record creation for unresolved or ambiguous folders.
    • unit-tests/test_command_folder.py: Add root duplicate creation, child-folder uniqueness, and destructive rmdir ambiguity coverage.
    • unit-tests/test_command_ksm.py: Add duplicate classic and NSF Secrets Manager application tests.

Prevent attacker-owned shared-in folders from shadowing victim folder
paths during NSF record operations. Restrict name resolution to owned
folders, prefer owned records during title lookup, reject ambiguous
matches, and add regression coverage for record creation and resolution.
@sshrushanth-ks sshrushanth-ks self-assigned this Oct 16, 2026
@sshrushanth-ks
sshrushanth-ks marked this pull request as ready for review October 16, 2026 12:01

@adeshmukh-ks adeshmukh-ks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working on additional changes

and reject path results containing unowned NSF folders.

Add regression coverage for attacker-owned NSF folders present in
folder_cache.
…folder path components match multiple folders instead of selecting the first result.

Prevent record-add from creating unfiled records when --folder cannot be
resolved, and add regression coverage for duplicate folder names across
record and folder commands.
@sshrushanth-ks sshrushanth-ks changed the title KC-1504: Fix Nested Share Folder path resolution ownership bypass KC-1504, KC-1519: Fix Nested Share Folder path resolution ownership bypass, Prevent duplicate folder names from routing records into attacker-owned shared folders Oct 23, 2026
@sshrushanth-ks sshrushanth-ks changed the title KC-1504, KC-1519: Fix Nested Share Folder path resolution ownership bypass, Prevent duplicate folder names from routing records into attacker-owned shared folders KC-1504, KC-1519: Fix Nested Share Folder path resolution ownership bypass, and Prevent duplicate folder names from routing records into attacker-owned shared folders Oct 23, 2026
Prevent first-match selection for duplicate or attacker-owned NSF folders and records. Reject ambiguous classic folder paths before destructive operations, route Secrets Manager application lookup through the duplicate-safe resolver, and add regression coverage for NSF, classic, shortcut, rmdir, and Secrets Manager scenarios.
Fail closed when parent paths resolve to multiple folders, preventing mkdir, mv, and record-add --folder from routing keys into attacker-owned shared folders. Preserve valid duplicate root names in mkdir and nsf-mkdir while enforcing unique child-folder resolution.
@sshrushanth-ks sshrushanth-ks changed the title KC-1504, KC-1519: Fix Nested Share Folder path resolution ownership bypass, and Prevent duplicate folder names from routing records into attacker-owned shared folders KC-1504, KC-1519, KC-1526: Fix NSF ownership bypass and attacker-shared folder name collisions in mkdir, mv, ln, and record-add --folder Oct 29, 2026
- Preserve root mkdir/nsf-mkdir idempotency for owned folders
- Resolve exact-case names before case-insensitive fallbacks
- Prefer owned folders and records while failing closed on collisions
- Support unique shared-in NSF folder paths and KSM app lookups
- Surface ambiguity errors in ls, tree, and cd
- Add regression tests for folder, record, NSF, and KSM resolution

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants