Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanupInternalCRLMapping double slash path delete trips up zookeeper backend #30144

Open
juliantaylor opened this issue Apr 1, 2025 · 1 comment
Labels
bug Used to indicate a potential bug secret/pki storage/zookeeper

Comments

@juliantaylor
Copy link

the delete on the storage in _cleanupInternalCRLMapping in builtin/logical/pki/issuing/config_revocation.go passes a path with two consecutive slashes to the backend, e.g. when baseCRLPath is "unified-crls/" in the !isLocal case

            if err := s.Delete(ctx, baseCRLPath+"/"+crl); err != nil {
                    return fmt.Errorf("failed cleaning up orphaned CRL %v: %w", crl, err)
            }

While probably no issue for the default backends it trips up the zookeeper one in cleanupLogicalPath

URL: PUT ....:8200/v1/ui/.../root/generate/internal
 
* 1 error occurred:
    * unable to update local CRL config's modification time: error persisting local CRL config: failed to clean up internal CRL mapping: failed cleaning up orphaned CRL c6e199ee-8f9c-18e0-d07b-c541f9c1ff71-delta: failed to acquire node data: zk: invalid path

adding filepath.Clean to the splitting in cleanupLogicalPath (nodes := strings.Split(filepath.Clean(path), "/")) or properly joining in _cleanupInternalCRLMapping fixes the problem

@heatherezell heatherezell added bug Used to indicate a potential bug secret/pki storage/zookeeper labels Apr 1, 2025
@juliantaylor
Copy link
Author

following unittest addition reproduces it:

--- a/sdk/physical/testing.go
+++ b/sdk/physical/testing.go
@@ -154,6 +154,18 @@ func ExerciseBackend(t testing.TB, b Backend) {
                t.Fatalf("failed to remove deep nest: %v", err)
        }
 
+       // Removal duplicated separators should not fail or leave artifacts
+       e = &Entry{Key: "foo/nested1//nested2/nested3", Value: []byte("baz")}
+       err = b.Put(ctx, e)
+       if err != nil {
+               t.Fatalf("deep nest: %v", err)
+       }
+
+       err = b.Delete(ctx, "foo/nested1//nested2/nested3")
+       if err != nil {
+               t.Fatalf("failed to remove deep nest: %v", err)
+       }
+
--- FAIL: TestZooKeeperBackend (0.09s)
    zookeeper_test.go:57: failed to remove deep nest: failed to acquire node data: zk: invalid path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug secret/pki storage/zookeeper
Projects
None yet
Development

No branches or pull requests

2 participants