Repository navigation
fix: write login entries in the shape the Enpass app expects - #165
Merged
Merged
Conversation
CreateEntry wrote a partial item row: item.template was left NULL, category used the wrong case, icon was a bare string, and only three itemfield rows were written with invented uids and no order. Enpass 6.12 dereferences item.template with strlen() while rendering and crashes with EXC_BAD_ACCESS (KERN_INVALID_ADDRESS at 0x0); builds that tolerate the NULL show the values without labels or section grouping. Write the complete stock login.default template (uids 10, 12, 11, 13, 101, 14, 102, 15, 16 with orde 1-9), lower-case the category, store the JSON icon the app expects, and fill the per-field metadata (hash, initial, strength, algo_version, timestamps). UpdateEntry had two related defects: it generated a new item key and re-encrypted only the password, leaving the item's other sensitive fields encrypted under a discarded key, and it matched fields by type alone, so every password row in the item was overwritten. Reuse the existing item key, target the template uid (falling back to the first field of that type so entries written by older versions are repaired in place), and refresh hash/initial/strength. Both paths keep vault.json's vault_items_count and last_modified_time in step, and only fill columns that exist in the vault, since the itemfield schema differs between vault versions (6.8 vs 6.12). Creating a non-login category now returns an error instead of writing a row the app cannot map onto a template.
| return "" | ||
| } | ||
|
|
||
| sum := sha1.Sum([]byte(value)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Entries created or edited with
enpass-cliare not shaped the way the Enpass app expects. On Enpass 6.12.8 (macOS) an entry created byenpass-climakes the app crash while drawing the item list. On builds that tolerate the row, the entry loads but shows bare values: no field labels, no section grouping, no icon.Two separate problems, both in
pkg/enpass/write.go:CreateEntrywrites a partialitemrow and threeitemfieldrows with invented uids and no display order.UpdateEntryreplacesitem.keyand re-encrypts only the password, which invalidates the item's other sensitive fields, and it matches fields bytypealone, so every password field in the item is overwritten.Why the app crashes
The app resolves a field's label and section through the item template:
(item.template, itemfield.item_field_uid, orde). The writer leftitem.templateNULL:Crash report from the app:
i.e.
strlen(NULL)onitem.template.What this changes
Create
itemrow:template,meta_updated_at,updated_at,auto_submit,usage_count,last_used,wearable,form_data,extra, JSON iconlogin.defaultfield set: uids10, 12, 11, 13, 101, 14, 102, 15, 16,orde1-9, with the app's sensitive flags, plushash(SHA-1 of the plaintext),initial,strength,algo_version,historical,pwned_check_timevault.json:vault_items_countandlast_modified_timekept in stepUpdate
item.key; only encrypt the field being changedhash/initial/strengthand the item timestampsSchema differences
Column sets differ between vaults of different ages: the vault bundled in
test/has 23itemfieldcolumns, a 6.12-created vault has 25 (non_compliant,non_compliant_check_time). Inserts are therefore built frompragma_table_infoand skip columns the vault does not have, instead of hard-coding a list that breaks on another version.Verification
item.keyunchanged and both fields decrypt; before this patch the second field became undecryptablego test ./...passesKnown limitation
The stock template is hard-coded. It cannot be read from the vault: on stock vaults the
templateandcategorytables are empty and the definitions ship inside the app bundle. The uids and order here were taken from items written by Enpass 6.12; the fields shared with 6.8-era items match.A more future-proof approach — a good follow-up — is to copy the skeleton from an existing item of the same template in the same vault (the template-provided slots are exactly the fields with an empty
label), falling back to this constant only when the vault has no such item. That needs a fallback path and a policy for custom fields, so it is not folded into this fix.Follow-ups