Skip to content

CSRF middleware planned before introducing any cookie-based auth #217

Closed

Description

@kilodesodiq-arch

Problem Statement. security.module.ts carries an explicit comment:

/**
 * WARNING:
 * If cookie-based session management or any browser-managed credentials are introduced
 * in the future, CSRF protection middleware MUST be implemented.
 */

There is no ticket tracking that future obligation. Re-introducing a cookie or
SameSite=None; Secure flow without realising the gap is a one-line PR away from a regression.

Why it matters. CSRF defences are only as good as their visibility. Embedding the
expectation into the source-of-truth PR queue prevents regressions.

Technical Context. Today the API is API-key-authenticated, custom-header-based, so
browsers do not auto-attach the credential. Adding cookie-parser (not currently
installed) would silently change the threat model.

Expected Outcome. An informational PR is opened that documents the existing CSRF
posture, the conditions under which it would break, and a CsrfMiddleware skeleton guarded
behind a feature flag.

Acceptance Criteria.

  • A new src/common/security/csrf.middleware.ts is registered only when
    CSRF_PROTECTION_ENABLED=true.
  • A CI test verifies CSRF is bypassed (current posture) and a second test verifies it
    blocks a forged POST when enabled.
  • A short docs/security/csrf-posture.md covers the contract.

Implementation Notes. Use csurf/csrf-csrf packages only if still maintained; else
build a 30-line double-submit-cookie middleware to keep the dependency surface small.

Files or modules likely to be affected. src/common/security/csrf.middleware.ts,
docs/security/csrf-posture.md.

Difficulty. Medium
Estimated effort. S



Backlog item #9 from `docs/maintainer-issue-backlog.md.

Activity

  1. Jumongweb commented on Jul 15, 2026

    @Jumongweb
    Contributor

    Hi maintainer, i will like to solve this issue

  2. Clement-coder commented on Jul 20, 2026

    @Clement-coder

    Hi,

    I’m a full-stack software and blockchain engineer with hands-on experience delivering production-ready solutions across frontend, backend, and blockchain systems.

    I’d like to take ownership of this issue. I’ve reviewed the requirements and can implement a scalable, maintainable, and well-tested solution that fully satisfies the acceptance criteria.

    Ready to start immediately and keep the team updated throughout the process.

  3. YAustinXYZ commented on Jul 21, 2026

    @YAustinXYZ

    Good morning, I wanna make this issue, i have experiencie working with this type of technologies.

  4. ZionApprove commented on Jul 21, 2026

    @ZionApprove
    Contributor

    assign me this.

  5. grantfox-oss commented on Jul 21, 2026

    @grantfox-oss

    🦊 GrantFox — @ZionApprove has been assigned to this issue as part of the Official Campaign | FWC26 campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #217)
    2. Your PR will be reviewed by the ChainForgee maintainers

    Good luck! Track your progress on GrantFox.

  6. added a commit that references this issue on Jul 22, 2026
    72215d4
  7. grantfox-oss commented on Jul 22, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!

    @ZionApprove's PR #405 was approved and merged by @kilodesodiq-arch.

    🏆 @ZionApprove: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (153 total points). Track your full progress on GrantFox.

    👏 Great work, @ZionApprove! Keep contributing to ChainForgee.

  8. added a commit that references this issue on Jul 23, 2026
    c9021df
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