Skip to content

csrf logic is flawed #597

Closed
Closed
@mmerickel

Description

@mmerickel

Apologies for the structure of this issue. I am not a go developer, nor a user of echo and thus do not have any working code examples.

I was linked to the CSRF implementation in echo by someone with some questions about how it works. As I've looked through its logic, it appears to be fundamentally broken and failing to serve its purpose of protecting against malicious third-party websites. It appears as if any token signed using the global secret is considered a valid CSRF token. This means that an attacker only needs to acquire a single token from the server, and then they can forge a malicious form which can be used against visitors.

Attack:

  • Attacker requests any page on the site.
  • Attacker grabs the token from the cookie.
  • Attacker builds new website with a form that posts back to your website with a copy of your delete account form using the hijacked token.
  • Visitor clicks the button on the attackers website, triggering a post with a valid csrf token and their auth credentials.
  • Visitor's account is now deleted.

This type of automated attack should be impossible if CSRF were implemented properly. The token must be tied to the user or the user's logged in session in some way to make it unguessable. Currently the token is only tied to a global secret, making any token valid for any user and only protecting against the most naive attack in which an attacker creates a form with no csrf token at all. The tokens also never expire which is poor design as it's standard practice to change security tokens when a user crosses a privilege boundary (such as logging in or out).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions