Skip to content

the credential store disagrees with itself about what a credential is: two key-splits, an index erased by its own migration, login-pinned writes, and no prune verb #9

Closed

Description

@aitrawog

Finding (RCA, R1) — the credential store disagrees with itself about what a credential IS

Verified live on 2026-11-16 (charly 2026.319.1133, plugin-secrets at v2026.314.0715), then read in
source. Five findings, one cutover: the store resolves one identity per credential, keeps its shadow
index truthful, honours its collection pin, and ships the verb its own messages promise.

1. The same credential has two identities — the config-side parser splits at the FIRST slash, every other parser at the LAST

parseCompositeKey (candy/plugin-secrets/credential_config.go:206-220) resolves a vnc_passwords map key
to (service, key) by hard-coding two prefixes (charly/secret/, charly/enc/) and otherwise cutting at the
first slash. Every other parser in the tree cuts at the last:

surface split
credential_config.go:196 PlaintextCredentialEntries → drives migrate-secrets + import FIRST slash
verb_credential.go:145 the doctor's index-consistency probe FIRST slash
command.go:339 collectCredentialNames → drives list + export LAST slash
sdk/deploykit/secret_provision.go:280 CollectCandySecretAccepts (the deploy WRITE path) LAST slash
sdk/deploykit/secret_candy_resolve.go:48 EnsureCandySecret (artifacts / secret_require) LAST slash
plugin-deploy-pod secret_migration.go:59 secretKeyForDep (config -e) LAST slash

So for the documented shared namespace charly/<ns>/<name> with ns ∉ {secret, enc} — e.g.
charly/api-key/openrouter, which /charly-build:secrets recommends — the writer stores
service=charly/api-key, key=openrouter while the config-side parser reads back
service=charly, key=api-key/openrouter. A D-Bus item's identity IS its attribute pair, so the two never meet.

Measured (sandbox XDG_CONFIG_HOME, throwaway keys, real keyring, entries deleted after):

$ printf 'vnc_passwords:\n    charly/api-key/auditprobe: API-VALUE\n' > $XDG_CONFIG_HOME/charly/config.yml
$ plugin-secrets import --dry-run
  charly/api-key/auditprobe                          (from config.yml)
$ plugin-secrets import
  charly/api-key/auditprobe  → keyring ✓ (from config)
$ plugin-secrets get charly/api-key auditprobe
charly secrets: no entry found for charly/api-key/auditprobe     # the documented identity
$ plugin-secrets get charly api-key/auditprobe
API-VALUE                                                        # the mis-split identity

Live blast radius on an ordinary host — the doctor reports a false positive on three credentials that
are demonstrably present, and prescribes a re-store that would duplicate them:

[!] Keyring index consistency -- indexed but not found in any collection:
    charly/api-key/openai, charly/api-key/qdrant, charly/api-key/whisper
    (Re-store with `charly secrets set <service> <key>` or prune stale index entries)

$ plugin-secrets get charly/api-key openai      → rc=0, a 14-byte value

migrate-secrets is worse than a false alarm: it MOVES the value to the mis-split coordinate and then
deletes the plaintext, so the credential survives but is unreachable by the name the operator knows.

Missed control. No test drives a two-segment service through PlaintextCredentialEntries:
TestPlaintextCredentialEntriesCompositeKeys covers charly/secret/... (a hard-coded prefix) only, so the
first-slash cut has never been exercised on the namespace the skill recommends. charly box validate cannot
see it, and the doctor's own probe shares the bug, so the system's self-check agrees with its defect.

Root fix. ONE split, the last-slash rule every writer already uses, used by all three consumers; delete
the hard-coded prefix table (knownServicePrefixes) with it. Keys cannot contain / (the CUE key: regex is
^charly/[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9_-]*$, and env-var names cannot either), so last-slash is
unambiguous.

2. migrate-secrets erases the index entry it just wrote — and strips the plaintext of entries it could NOT move

ConfigMigrateSecretsCmd.Run (credential_admin.go:118-141) migrates with keyring.Set, which appends the
shadow-index entry to config.yml and saves. After the loop it mutates its stale in-memory cfg
(cfg.VncPasswords = nil) and calls SaveRuntimeConfig(cfg) — writing the KeyringKeys slice it loaded
BEFORE any of those saves. Every index entry added by this run is dropped.

Measured (sandbox config seeded with one pre-existing index entry + one plaintext entry):

$ plugin-secrets migrate-secrets
  charly/secret.NEW_MIGRATED                     → keyring ✓
Removed plaintext credentials from config.yml.

$ cat $XDG_CONFIG_HOME/charly/config.yml
keyring_keys:
    - charly/secret/PRESET_ENTRY                  # the newly migrated entry is GONE
$ plugin-secrets list
charly/secret/PRESET_ENTRY                        # the migrated secret is invisible
$ plugin-secrets get charly/secret NEW_MIGRATED
NEW-VALUE                                         # …but its value is in the keyring
$ plugin-secrets export
{}                                                # silent data loss in the export

This fires on exactly the remediation the doctor prints: [!] Plaintext credentials -- 1 in config.yml (Run: charly secrets migrate-secrets --dry-run).

The same block clears the WHOLE plaintext map, so an entry whose keyring write FAILED is stripped too (code
read: the continue on failure leaves migrated > 0 true, and the wholesale VncPasswords = nil then
deletes the value that never reached the keyring). The sibling plugin-deploy-pod/secret_migration.go:153
already does this correctly for charly.yml — a delete-exactly-the-migrated-keys read-modify-write.

Missed control. No test asserts the index survives a migration; TestPlaintextCredentialEntries* test the
parser, not the command's persistence.

Root fix. Track the pairs that actually reached the keyring; after the loop, reload the config and delete
exactly those composite keys, then save once. One read-modify-write, no stale copy.

3. charly secrets prune does not exist, but the product tells operators to run it

credential_keyring.go:154-159: when a Get misses though the shadow index claims the key exists, the message
says "Run charly secrets prune to reconcile". The whole surface is
delete, export, get, gpg*, import, list, migrate-secrets, set:

$ plugin-secrets prune
plugin-secrets: parse `charly secrets [prune]`: unexpected argument prune     (rc=1)

So the one recovery path for index drift — which findings 1 and 2 both produce — does not exist.

Root fix. Implement charly secrets prune [--dry-run]: for every shadow-index entry, look up
(service, username) across the healthy collections with the SAME iteration the read path uses; drop the
entries that resolve nowhere; save once; report each action. This is the direction the message promises, and
it is deterministic and safe (it never writes a secret).

4. The WRITE path is hard-pinned to the Secret Service login collection: keyring_collection_label is not honoured, and delete silently no-ops outside it

KeyringStore.Set (credential_keyring.go:218-236) calls keyring.Set, and KeyringStore.Delete
(:238-256) calls keyring.Delete — github.com/zalando/go-keyring v0.2.8, whose Linux provider
(keyring_unix.go:41-52) resolves GetLoginCollection(): /org/freedesktop/secrets/collection/login, or the
login alias. The READ path (credential_keyring.go:181-202) iterates default → keyring_collection_label → every healthy collection. The two disagree, in two ways the docs promise they do not:

  • keyring_collection_label "pins charly to a specific collection" — reads yes, writes no. A KeePassXC
    database exposed as a non-login collection receives nothing; the secret lands in login (or the write fails
    outright where no login collection exists).
  • delete only finds items in login, and a not-found is tolerated as success
    (if err != nil && !isKeyringNotFound(err)), so deleting a credential that lives in any other collection
    prints Deleted … from keyring, removes its shadow-index entry, and LEAVES THE ITEM IN THE STORE. The
    operator loses the only pointer to it.

The primitives to do this correctly already exist and are already wired for the other half of this plugin:
resolveTargetCollection (secret_service.go:443) carries the comment "a key written under
keyring_collection_label: opencharly will be readable by a subsequent findItemByAttrsAcrossCollections call
with the same setting"
, and createItem/deleteItem are used by the GPG keystore path
(secrets_gpg.go:637-641) — with zero callers on the credential-store path. This is a built, tested, documented
capability that was never connected.

Root fix. Route KeyringStore.Set/Delete through the same ssClient the reads use
(resolveTargetCollection + createItem(..., replace=true); findItemByAttrsAnyCollection + deleteItem),
map the locked/all-broken errors onto the existing KeyringLockedError, and drop go-keyring — after this it
has no caller in the plugin, and an unused dependency is the same class of residue as a dead shim.

5. The secrets skill states three things the store does not do

Measured against the code, on the same reading:

skill claim reality
the env override is CHARLY_VNC_PASSWORD it is the bare VNC_PASSWORD (charly/check_endpoint_resolve.go:158,163); no CHARLY_-prefixed credential override exists (CHARLY_SECRET_BACKEND switches the backend, it is not a credential)
auto-generated tokens are "32-byte hex via generateRandomHex(32)" base64url of 32 bytes = 44 chars, sdk/deploykit/secret_probe.go:54-60; no function named generateRandomHex exists anywhere in the tree
charly secrets list reflects "the active store" it reflects the CONFIG FILE (shadow index + plaintext) whatever the backend — which is why finding 2 hides credentials from it

Plus the missing prune verb and the collection-label half of finding 4 once they exist. R4 applies: the
product is fixed first (findings 1-4), then the prose.
Editing the skill to describe today's pinning
behaviour would be documenting the defect.

Blast radius of the doc rows. Every operator who stores a credential under a charly/-prefixed env
override (a documented first-time-setup step) gets a value that ResolveCredential finds and charly secrets get does not, and the skill is where they learn the name to use.

Related, and NOT fixed here

Fix plan — one cutover in this repo

  1. fix(secrets): one composite-key split (parseCompositeKey learns last-slash, knownServicePrefixes
    deleted, collectCredentialNames calls it) + a test on the two-segment namespace that fails today.
  2. fix(secrets): migrate-secrets migrates, then one fresh read-modify-write deleting exactly the migrated
    composite keys; a failed entry keeps its plaintext. Test asserts the index survives.
  3. feat(secrets): charly secrets prune [--dry-run], built on the read path's own iteration.
  4. feat(secrets): Set/Delete through resolveTargetCollection/createItem/deleteItem; go-keyring
    removed with its last caller; description prose swept.
  5. docs(skill): the four rows above, plus prune in the quick reference.
  6. Corpus leg in opencharly/marketplace, producer-first after this lands and tags: bump the
    plugin-secrets pin and regenerate the build/secrets projection.

Evidence provenance

Live: findings 1 (import + doctor), 2 (sandbox migration), 3 (prune rc=1), 4 (go-keyring source read +
the live keyring_collection_label read path), 5 (source read + live value lengths). Code-read, marked as
such: finding 2's failed-entry plaintext strip.
All throwaway credentials used for the measurements were deleted afterwards; the host's
~/.config/charly/config.yml differs from its pre-session state only by the removal of the probes.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

Activity

  1. self-assigned this
    on Nov 15, 2026
  2. aitrawog commented on Nov 15, 2026

    @aitrawog
    ContributorAuthor

    CLAIM — I am taking issue #9: the credential store's identity, index, and collection pinning.

    Scope, one cutover in this repo:

    1. one composite-key split (last-slash) shared by PlaintextCredentialEntries, the doctor probe and collectCredentialNames;
    2. migrate-secrets saving once from a fresh read-modify-write, deleting only the pairs that reached the keyring;
    3. charly secrets prune [--dry-run], the verb the drift message already names;
    4. Set/Delete through resolveTargetCollection + createItem/deleteItem (the primitives the GPG path already uses), go-keyring dropped with its last caller;
    5. the secrets skill's four false rows, after the product is fixed (R4).

    Branch feat/store-identity-and-index in a session worktree off fresh origin/main. The corpus leg (opencharly/marketplace: pin bump + regenerated build/secrets projection) follows producer-first after this lands.

    Agent: charly

    Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

  3. aitrawog commented on Nov 15, 2026

    @aitrawog
    ContributorAuthor

    STATUS — the cutover is open as #10 (head 554c11ba0ce55c5491a70f687ee915425027228f).

    Landed in the branch: one composite-key split (prefix table deleted, collectCredentialNames calls it);
    migrate-secrets saving once from a fresh read-modify-write and stripping only the pairs that reached the
    keyring; charly secrets prune [--dry-run]; Set/Delete through resolveTargetCollection +
    createItem/deleteItem with go-keyring removed and its three prose claims swept; and the secrets
    skill's false rows.

    Next: the opencharly/marketplace corpus leg (pin bump + regenerated build/secrets projection),
    producer-first after #10 merges and tags. Due immediately after the merge.

    One correction to this issue's finding 4, measured after filing — the mechanism is narrower than I
    wrote. go-keyring v0.2.8's Linux provider resolves ONE collection: /org/freedesktop/secrets/collection/login
    when it exists, else the default alias path (keyring_unix.go:41-52, secret_service.go:97-103). It is
    not "the login collection only", so on a host whose login collection is absent (like this one) writes and
    deletes did land in default — where reads also start — and no defect was observable there. The two real
    consequences stand: keyring_collection_label was ignored by every write and delete (the documented pin
    held on reads only, which is exactly the multi-database case the key exists for), and a credential living in
    any collection other than the one go-keyring resolves could not be deleted — Delete printed success,
    dropped its index entry, and left the item in the store. The PR body and the fixed code carry the corrected
    mechanism.

    Agent: charly

    Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

  4. aitrawog commented on Nov 15, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — landed as #10 (squash 7126737), tagged v2026.319.2321,
    CHANGELOG 2026.319.2321.

    All five findings are fixed in the tree, not deferred: the one composite-key split, migrate-secrets
    saving once from a fresh read-modify-write (and keeping the plaintext of a failed write),
    charly secrets prune [--dry-run], Set/Delete through the same ssClient as Get with go-keyring
    removed, and the secrets skill's false rows corrected after the product was.

    The corpus leg (bump the plugin-secrets pin in opencharly/marketplace and regenerate the
    build/secrets projection) follows producer-first now that the tag exists.

    Agent: charly

    Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions