Skip to content

Comments

fix(frontend): security hardening for Electron, UI inputs, and store logic#1313

Open
eren-karakus0 wants to merge 2 commits intoeigent-ai:mainfrom
eren-karakus0:fix/frontend-electron-security-hardening
Open

fix(frontend): security hardening for Electron, UI inputs, and store logic#1313
eren-karakus0 wants to merge 2 commits intoeigent-ai:mainfrom
eren-karakus0:fix/frontend-electron-security-hardening

Conversation

@eren-karakus0
Copy link
Contributor

@eren-karakus0 eren-karakus0 commented Feb 19, 2026

Related Issue

Closes #1330

Split from #1299 as requested by @bytecii.

Summary

Security hardening for the frontend and Electron codebase.

Changes

  • fileReader.ts: Sanitize file paths to prevent path traversal
  • index.ts (electron): Harden IPC handlers
  • update.ts: Auto-update signature verification hardening
  • input.tsx / textarea.tsx: Add maxLength and input sanitization
  • chatStore.ts: Fix division-by-zero in percentage calculation
  • index.ts (lib): Sanitize URLs to prevent XSS via javascript: protocol

Tests

  • fileReader.test.ts — new, covers path traversal prevention
  • securityFixes.test.ts — new, covers URL sanitization
  • chatStore-divisionByZero.test.ts — new, covers division-by-zero edge case

Files (10)

  • electron/main/fileReader.ts
  • electron/main/index.ts
  • electron/main/update.ts
  • src/components/ui/input.tsx
  • src/components/ui/textarea.tsx
  • src/lib/index.ts
  • src/store/chatStore.ts
  • test/unit/electron/fileReader.test.ts
  • test/unit/lib/securityFixes.test.ts
  • test/unit/store/chatStore-divisionByZero.test.ts

…logic

- Sanitize file paths in Electron fileReader to prevent path traversal
- Harden Electron IPC handlers and auto-update signature verification
- Add maxLength and input sanitization to UI input/textarea components
- Fix division-by-zero in chatStore percentage calculation
- Sanitize URLs in lib/index.ts to prevent XSS via javascript: protocol
- Add tests for all changes
@Wendong-Fan
Copy link
Contributor

thanks @eren-karakus0 for the contribution, could you link the issue this pr want to resolve? maybe @bytecii and @a7m-1st could help reviewing this

@eren-karakus0
Copy link
Contributor Author

Linked - closes #1330. Thanks for the reminder @Wendong-Fan!

}
});

// ======================== skills ========================
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why we remove these?

Copy link
Contributor Author

@eren-karakus0 eren-karakus0 Feb 22, 2026

Choose a reason for hiding this comment

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

This was an accidental deletion. The skills section, unzipper import, and seedDefaultSkillsIfEmpty() call have all been restored. The only intended changes in index.ts are the 3 security fixes (OAuth token redaction, shell.showItemInFolder, log level downgrade). Fixed in latest push.

The previous commit unintentionally deleted the entire skills IPC
handlers (~400 lines), the unzipper import, and the
seedDefaultSkillsIfEmpty() call. This commit restores all removed
code while keeping the 3 intended security fixes:
- Redact OAuth token in logs
- Replace shell.openPath with shell.showItemInFolder
- Downgrade protocol code log from error to info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Frontend/Electron security: XSS in file parsers, unsigned updates, arbitrary file exec, weak RNG, secret leak

3 participants