Skip to content

sec: apply verify_token guard to search routers and refactor dispatch…#108

Open
goyalpreeti009 wants to merge 2 commits into
PandyaJeet:mainfrom
goyalpreeti009:fix/unauthenticated-search-endpoints
Open

sec: apply verify_token guard to search routers and refactor dispatch…#108
goyalpreeti009 wants to merge 2 commits into
PandyaJeet:mainfrom
goyalpreeti009:fix/unauthenticated-search-endpoints

Conversation

@goyalpreeti009

Copy link
Copy Markdown

Closes #82. Implements strict endpoint authorization on all search routes to prevent unauthorized cross-origin resource exploitation. This patch completely locks down direct HTTP endpoints over local loopback and securely routes internal app searches through Electron's Inter-Process Communication (IPC) layer.

🛠️ Changes Implemented
FastAPI Backend Protection: Modified backend/main.py to import and apply the verify_token dependency guard directly onto the seo.router, ai.router, and community.router mounting blocks.

Secure Electron IPC Listeners: Added search:seo, search:ai, and search:community handlers within main.cjs that utilize the local main process's fetchContext helper to automatically append the valid x-session-token header.

Context Bridge Exposure: Updated preload.cjs to safely expose the new search handlers to the renderer space via a search utility block.

Frontend Dispatch Refactoring: Restructured the performSearch loop inside frontend/src/App.jsx to direct all default app queries safely through window.superBrowserDesktop.search instead of issuing naked, unauthenticated HTTP network calls.

🧪 Verification Results
Direct external requests from standard web browsers (e.g., fetch('http://127.0.0.1:8000/api/search/ai?q=test')) now instantly fail with a 401 Unauthorized status code.

All internal functionalities for SuperSEO, SuperAI, and Community review load perfectly with zero regressions because the app securely signs the requests through the IPC tunnel.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @goyalpreeti009, thanks for your contribution! ⭐

This repository requires contributors to star the repository before a
pull request can be merged.

Please star the repo: https://github.com/PandyaJeet/SuperBrowser

Once you've starred it, push any commit (or reopen the PR) to re-run this
check and it will turn green. Thank you! 🎉

@itsdakshjain itsdakshjain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

excellent security hardening with the new ipc routing, but please clean up the duplicate function signatures and the process.env fallback left in frontend/src/App.jsx before merging.

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.

fix: Unauthenticated search endpoints allow any website to drain Groq and SerpAPI quota

2 participants