zeppelin icon indicating copy to clipboard operation
zeppelin copied to clipboard

[ZEPPELIN-6142] Apply synchronizer token pattern to terminal interpreter for CSWSH protection

Open seung-00 opened this issue 1 year ago • 1 comments

What is this PR for?

This PR applies synchronizer token pattern to terminal interpreter for CSWSH protection. The terminal interpreter is reported with a CSWSH(Cross-Site WebSocket Hijacking) vulnerability. An earlier PR partially addressed this issue by implementing an origin check. However, this measure does not provide full protection, as it can't prevent attacks from scripts running within the same origin.

To enhance security, I implemented the synchronizer token pattern as an additional layer of protection. I modified the terminal HTML to be rendered with a Jinja template, allowing a CSRF token to be injected. This CSRF token is then validated on receiving the first WebSocket message, providing robust protection against CSWSH attacks.

References:

What type of PR is it?

Improvement

Todos

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-6142

How should this be tested?

  1. After removing the origin check(by making the checkOrigin method always return true), connect to the terminal WebSocket and send a message without a valid CSRF token.
  2. Check that the connection is promptly closed and that an error is logged on the server.

Screenshots (if appropriate)

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

seung-00 avatar Nov 03 '24 15:11 seung-00

@tbonelee Thank you for the review. I’m going to give some more thought to the CSRF token theft issue that you mentioned, and add a commit for it.

seung-00 avatar Nov 04 '24 17:11 seung-00