Skip to content

The access token is kept in a JavaScript-readable cookie and fetches don't send credentials #1975

Closed

Description

@yusuftomilola

Problem

After login, useSessionStore.setAccessToken writes the JWT with js-cookie (no HttpOnly), and every API module reads it back and sends it as a bearer header. Any XSS can read it. Meanwhile lib/auth-api.ts calls fetch without credentials: "include" (only wallet-api.ts sets it), so the backend's HttpOnly cookie is dropped for cross-origin requests and two auth mechanisms coexist.

Proposed change

Pick one model: let the backend own an HttpOnly cookie (all fetches use credentials: "include", CORS already allows credentials) and remove token handling from the client, or keep bearer tokens in memory with short lifetimes and refresh. Update middleware, RequireAdmin and every *-api.ts accordingly.

Acceptance criteria

  • The token is not readable from document.cookie.
  • Login, refresh and logout work end to end against the real API.

Activity

  1. ykargeee-bit commented on Oct 17, 2026

    @ykargeee-bit
    Contributor

    @ykargeee-bit has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi Maintainer,

    I’m a full-stack developer, and I’d like to contribute to the task. I’ll implement it carefully and efficiently thoroughly understand requirements and edge cases
    Communicate promptly about suggestions or improvements. And I will provide regular progress updates and address blockers
    Align with project goals through feedback and clarification.

    Thank you,

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @ykargeee-bit to this issue.

  2. liutingqiu commented on Oct 17, 2026

    @liutingqiu

    @liutingqiu has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    The token is written with js-cookie and read back into a bearer header, so any XSS owns the session; meanwhile only wallet-api.ts sends credentials, so the backend's HttpOnly cookie is dropped everywhere else and two auth mechanisms coexist.Plan: pick the cookie model and make it consistent — remove token handling from the client (no more js-cookie), add credentials: "include" to every *-api.ts, update RequireAdmin and the middleware, and delete the now-dead bearer path. Acceptance is verified by document.cookie no longer containing the token and by login/refresh/logo

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @liutingqiu to this issue.

  3. drips-wave commented on Oct 17, 2026

    @drips-wave

    Congratulations, @ykargeee-bit! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @ykargeee-bit: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  4. grantfox-oss commented on Oct 18, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @ykargeee-bit's PR #2049 was approved and merged by @yusuftomilola.

    🏆 @ykargeee-bit: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,865 total points). Track your full progress on GrantFox.

    👏 Great work, @ykargeee-bit! Keep contributing to DistinctCodes.

  5. drips-wave commented on Oct 18, 2026

    @drips-wave

    This issue has been completed by @ykargeee-bit as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @ykargeee-bit: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  6. added 3 commits that reference this issue on Oct 18, 2026
    f4dfea1
    2352775
    4922f83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions