Skip to content

fix: address 16 verified bugs from Faultmark report (#2829) - #1

Merged
Abzaek merged 46 commits into
mainfrom
fix/faultmark-verified-bugs
Jun 4, 2026
Merged

Abzaek merged 46 commits into
mainfrom
fix/faultmark-verified-bugs

Conversation

@Abzaek

@Abzaek Abzaek commented Jun 4, 2026 •

Copy link
Copy Markdown
Owner

Closes documenso#2829.

Went through the Faultmark report and fixed 16 issues. Most were straightforward — stale deps, missing guards, things that break under specific conditions but feel obvious once you see them. A couple were worth explaining.

Bug documenso#8 — spinner destruction timing

This one took a second look. The report flagged destroy() being called twice on the signature field's Konva spinner group. That was misleading — the real problem is more subtle. When the user needs to reauthenticate (2FA, passkey), the original code called destroy() in .finally() which fires immediately after the auth dialog opens. So the spinner vanishes while the dialog is still on screen. Then onReauthFormSubmit fires later and calls destroy() again on an already gone group.

Claude's first fix replaced .finally() with .catch(), but that introduced a leak — if the user cancels the auth dialog, the spinner never gets cleaned up and sits there on the canvas forever since the field is already signed.

The fix: a destroySpinnerOnce guard. Both onReauthFormSubmit and .finally() call it, but only the first call actually runs. This keeps the spinner visible during auth (correct UX) and cleans up on cancel (no leak).

The other 15 fixes sorted by category:

What Where Why
XSS via dangerouslySetInnerHTML app-banner.tsx Banner content came from API with no sanitization
React hooks
Missing deps in useMemo/useCallback security.sessions.tsx, configure-document-recipients.tsx, document-signing-number-field.tsx Seven empty or stale dependency arrays causing stale closures
Stale selectedTemplateId in callback public-profile-template-manage-dialog.tsx Closure captured value from the wrong render
Stale isOpen from nested state app-command-menu.tsx v.open from the loop was being read stale
Edge cases
teamUrl could be null app-command-menu.tsx Two navigation functions would crash when user isn't in a team
transferTeamId could be -1 team-delete-dialog.tsx Sent -1 to the API as a valid user ID
Math.max() with single argument configure-fields-view.tsx No-op, returned the argument unchanged
for...of on Storage.key() with mutation document-edit-form.tsx Skipped every other key because keys shift during iteration
Data & form
Field duplication kept the wrong recipient configure-fields-view.tsx Used sidebar selection instead of the original field's recipient
Radio form calling both field.onChange and form.setValue editor-field-radio-form.tsx Double-write caused React to reconcile the wrong value
Shared new UAParser() across cell renders security.sessions.tsx Parser has internal state, could produce wrong output under load
Infinite re-render on team settings page o.$orgUrl.settings.teams.tsx setSearchParams in useEffect triggered itself

Made sure nothing was already addressed upstream before touching it.

roshboi and others added 30 commits May 21, 2026 15:49
## Description
Updated HIPAA status to compliant
Reject disposable / throwaway email providers (mailinator, yopmail,
10minutemail, ...) across all signup paths: email/password, Google,
Microsoft, personal OIDC and organisation OIDC. Backed by the
mailchecker package (offline, ~55k domains, subdomain-aware).

Exposes a SIGNUP_DISPOSABLE_EMAIL error code so the signup form and
SSO redirect alert can show a dedicated message instead of the
generic 'signup disabled' one.
dguyen and others added 15 commits June 2, 2026 15:04
Apply fixes for the still-present bugs from the Faultmark scan:

- Bug #7: document-edit-form localStorage cleanup was skipping every other
  key because it removed items while forward-iterating the index. Collect
  keys first, then remove.
- Bug documenso#8: envelope signer page renderer was destroying the loading spinner
  in .finally() while the SIGNATURE field's re-auth dialog was still open
  (executeActionAuthProcedure resolves synchronously after opening). Move
  spinner teardown into onReauthFormSubmit and the non-auth branch so it
  only runs after the sign actually completes.
- Bug #9: security.sessions columns useMemo had empty deps but captured
  t, session, and refetch. Add them to the dependency array.
- Bug documenso#10: replace module-level UAParser instance (mutated across renders)
  with a per-cell `new UAParser(userAgent).getResult()` call.
- Bug documenso#11: sanitize site-banner HTML with isomorphic-dompurify before
  passing to dangerouslySetInnerHTML.
- Bug documenso#12/documenso#13: include signingOrder in the useCallback dep arrays for
  handleSigningOrderChange and onDragEnd so they don't close over a stale
  ordering mode.
- Bug documenso#14: field duplication now uses lastActiveField.signerEmail and
  recipientId unconditionally instead of preferring the currently selected
  recipient — duplicates were being re-assigned away from the field owner.
- Bug documenso#15: Math.max($page.offsetHeight, DEFAULT_HEIGHT_PX) and matching
  width; the previous single-arg Math.max calls dropped the page-size
  source entirely.
- Bug documenso#18: AppCommandMenu toggleOpen now computes newOpen once instead of
  passing the stale outer-scope isOpen to onOpenChange.
- Bug #19: goToDocuments/goToTemplates guard for empty link arrays so the
  shortcuts no longer throw when teamUrl is null.
- Bug documenso#20: public-profile-template-manage-dialog step calculation reads
  the freshly-derived newSelectedId rather than the (still-stale)
  selectedTemplateId state.
- Bug documenso#21: editor-field-radio-form computes the full final state and
  writes once instead of two sequential setValue calls that could briefly
  leave the previous option still checked.
- Bug documenso#22: team-delete-dialog forwards transferTeamId only when > 0, so
  the "Don't transfer" sentinel value of -1 is converted to undefined.
- Bug documenso#23: document-signing-number-field auto-sign effect adds onSign to
  its dep array so the captured closure stays in sync with the form state.
- Bug documenso#24: org teams settings effect now early-returns when the rebuilt
  URLSearchParams matches the current one, breaking the
  setSearchParams → searchParams change → effect re-runs loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…th auth dialog

The previous approach replaced .finally() with .catch(), which meant
the spinner was never destroyed if the auth dialog was dismissed by
the user (cancel/close) — the onReauthFormSubmit callback is only
invoked on successful auth submission.

The correct approach:
- Keep .finally() as the safety net for dialog cancel + error cleanup
- Use destroySpinnerOnce() guard to ensure the spinner is only destroyed
  once, even if both onReauthFormSubmit and .finally() fire
- Keep the spinner alive during the auth dialog (destroyed only inside
  onReauthFormSubmit after signField completes, not prematurely)
@Abzaek Abzaek changed the title fix: resolve Faultmark verified bugs and spinner lifecycle (#2829) fix: address 16 verified bugs from Faultmark report (#2829) Jun 4, 2026
@Abzaek
Abzaek merged commit a474496 into main Jun 4, 2026
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.

Faultmark scanned this repo and found 24 verified bugs