Skip to content

[PM-46254] fix(importer): preserve hidden and extra password-typed fields in Clipperz import - #24416

Closed
arxhr007 wants to merge 1 commit into
bitwarden:mainfrom
arxhr007:fix/clipperz-hidden-fields
Closed

arxhr007 wants to merge 1 commit into
bitwarden:mainfrom
arxhr007:fix/clipperz-hidden-fields

Conversation

@arxhr007

@arxhr007 arxhr007 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

fixes #24365

📔 Objective

The Clipperz importer loses or corrupts locked fields on exports that contain more than one:

  • Clipperz marks locked fields with hidden: true. The importer ignored the flag, so locked secrets landed in the vault as plain-text custom fields.
  • Every actionType/label mapping overwrote its target unconditionally. With several password-typed (locked) fields — the usual case, since Clipperz assigns actionType: "password" to locked secrets — the last field won the password slot and all earlier values were discarded entirely. Reporters saw a bogus value in the password field for exactly this reason.

Changes:

  • hidden: true fields import as FieldType.Hidden custom fields instead of plain text.
  • The password slot prefers a field actually labeled as a password. A displaced field, or any additional password-typed field, becomes a hidden custom field rather than overwriting or vanishing.
  • The same no-silent-overwrite guard is applied to the username and url slots so extra values are preserved as custom fields.

Regression tests added to clipperz-html-importer.spec.ts covering hidden-field import, multiple password-typed fields, and the labeled-password preference.

📸 Screenshots

…ed fields

Clipperz marks locked fields with hidden: true; they were imported as
plain-text custom fields or silently dropped. Multiple fields sharing an
actionType (e.g. several locked password-type fields) overwrote each
other unconditionally, so the last field won the slot and earlier values
were lost.

- hidden: true fields now import as hidden custom fields
- the password slot prefers a field actually labeled as a password; a
  displaced or additional field becomes a hidden custom field instead of
  vanishing
- the same no-silent-overwrite guard applies to username and url fields

fixes #24365
@arxhr007
arxhr007 requested a review from a team as a code owner November 4, 2026 10:42
@CLAassistant

CLAassistant commented Nov 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

const labelLower = field.label != null ? field.label.toLowerCase() : null;
const labeled =
labelLower != null && this.passwordFieldNames.indexOf(labelLower) > -1;
if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) {

@aikido-pr-checks aikido-pr-checks Bot Nov 4, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The password-slot condition combines || and &&, making its precedence harder to scan.

Suggested change
if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) {
const passwordSlotIsEmpty = cipher.login.password == null;
const shouldPreferLabeledPassword = labeled && !passwordFieldIsLabeled;
if (passwordSlotIsEmpty || shouldPreferLabeledPassword) {
Details

✨ AI Reasoning
​The password-slot selection condition combines || and && in one expression, requiring the reader to track operator precedence alongside the grouped checks. This makes the decision harder to scan than the surrounding conditions.

Reply on this comment to give feedback or ignore the issue.
More info

// Prefer a field actually labeled as a password: an earlier
// unlabeled field that held the slot is demoted to a hidden
// custom field rather than overwritten.
if (cipher.login.password != null && passwordFieldLabel != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The displaced-password check is nested five control-flow levels deep, making the password-slot handling difficult to follow.

Details

✨ AI Reasoning
​The password handling adds conditional branches inside the existing field iteration and switch. The displaced-password check is nested further within the slot-selection branch, making this path five control-flow levels deep and harder to follow.

🔧 How do I fix it?
Keep nesting levels under 4. Extract complex logic into separate functions when indentation exceeds 4 levels.

Reply on this comment to give feedback or ignore the issue.
More info

@bitwarden-bot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-46254
Link: https://bitwarden.atlassian.net/browse/PM-46254

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title fix(importer): preserve hidden and extra password-typed fields in Clipperz import [PM-46254] fix(importer): preserve hidden and extra password-typed fields in Clipperz import Nov 4, 2026
@bitwarden-bot bitwarden-bot added community-pr needs-qa Marks a PR as requiring QA approval labels Nov 4, 2026
Comment on lines +58 to +75
if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) {
// Prefer a field actually labeled as a password: an earlier
// unlabeled field that held the slot is demoted to a hidden
// custom field rather than overwritten.
if (cipher.login.password != null && passwordFieldLabel != null) {
this.processKvp(
cipher,
passwordFieldLabel,
cipher.login.password,
FieldType.Hidden,
);
}
cipher.login.password = this.getValueOrDefault(field.value);
passwordFieldIsLabeled = labeled;
passwordFieldLabel = field.label;
} else {
this.processKvp(cipher, field.label, field.value, fieldType);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will fix the Avoid deep nesting levels issue detected on line: 62.

Show Fix

Aikido AutoFix Patch Suggestion - medium confidence
This patch mitigates excessive control-flow nesting by introducing a guard clause in the password field handler to exit early when the password slot is already filled and should not be replaced, reducing the nesting depth of the displaced-password check from six to five levels.

Suggested change
if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) {
// Prefer a field actually labeled as a password: an earlier
// unlabeled field that held the slot is demoted to a hidden
// custom field rather than overwritten.
if (cipher.login.password != null && passwordFieldLabel != null) {
this.processKvp(
cipher,
passwordFieldLabel,
cipher.login.password,
FieldType.Hidden,
);
}
cipher.login.password = this.getValueOrDefault(field.value);
passwordFieldIsLabeled = labeled;
passwordFieldLabel = field.label;
} else {
this.processKvp(cipher, field.label, field.value, fieldType);
}
// If password slot is already filled and this field doesn't have priority, store as custom field
if (cipher.login.password != null && !(labeled && !passwordFieldIsLabeled)) {
this.processKvp(cipher, field.label, field.value, fieldType);
break;
}
// Prefer a field actually labeled as a password: an earlier
// unlabeled field that held the slot is demoted to a hidden
// custom field rather than overwritten.
if (cipher.login.password != null && passwordFieldLabel != null) {
this.processKvp(
cipher,
passwordFieldLabel,
cipher.login.password,
FieldType.Hidden,
);
}
cipher.login.password = this.getValueOrDefault(field.value);
passwordFieldIsLabeled = labeled;
passwordFieldLabel = field.label;

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@harr1424

harr1424 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Hi @arxhr007 and thanks for your first contribution to Bitwarden! It seems this PR fixes #24365 and duplicates #24371, the team will need some time to review and test both PRs before proceeding. We'll reach out and tag you here if any questions arise.

@arxhr007

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #24423, which includes the same Clipperz changes plus the KeePass2 fix. Thanks for pointing it out.

@arxhr007 arxhr007 closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-pr needs-qa Marks a PR as requiring QA approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clipperz data import is ignoring "hidden" fields and mapping the wrong password value

4 participants