Allow the v2 encryptor to serialize messages with `Marshal` by jcmfernandes · Pull Request #44 · rack/rack-session · GitHub
Skip to content

Allow the v2 encryptor to serialize messages with Marshal - #44

Merged
ioquatix merged 6 commits into
rack:mainfrom
jcmfernandes:v2-marshal
Jan 4, 2025
Merged

ioquatix merged 6 commits into
rack:mainfrom
jcmfernandes:v2-marshal

Conversation

@jcmfernandes

@jcmfernandes jcmfernandes commented Aug 9, 2024 •

Copy link
Copy Markdown
Contributor

This is a follow-up on #39 that must be merged first.

I deliberately avoided allowing Marshal serialization in the v2 encryptor because 1) Marshal has been a source of RCE vulnerabilities and 2) serializing messages as JSON allows for better interoperability, making it trivial to access sessions created with rack-session in other languages.

However, it's impossible to swap Marhal with JSON without breaking users' code that relies on Marhal behavior that JSON doesn't mimic (e.g., preserving ruby symbols).

So... I see 3 ways forward:

  1. We close this PR and release yet another major
  2. We close this PR and make v2 opt-in instead of the default
  3. We merge this PR

Happy to hear some feedback.

jcmfernandes and others added 5 commits February 13, 2024 09:25
This broke with the release of rack 3.1.x.
Marshal and JSON serialization are unavoidably different. A key
difference being that JSON serializes ruby symbols as strings, while
Marshal preserves them as symbols.
@ioquatix

ioquatix commented Aug 11, 2024 •

Copy link
Copy Markdown
Member

@jcmfernandes jcmfernandes changed the title Allow the v2 encrytor to serialize messages with Marshal Allow the v2 encryptor to serialize messages with Marshal Aug 12, 2024
@ioquatix

Copy link
Copy Markdown
Member

Just touching base here - any chance you are able to rebase on main?

@ioquatix ioquatix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's take the conservative approach for now, we can revisit making JSON the default later.

@ioquatix
ioquatix merged commit b772d26 into rack:main Jan 4, 2025
ioquatix pushed a commit that referenced this pull request Jan 4, 2025
Marshal and JSON serialization are unavoidably different. A key
difference being that JSON serializes ruby symbols as strings, while
Marshal preserves them as symbols.

* Support UTF-8 data when using the JSON serializer
* Replace all instance of 'BINARY' with `Encoding::BINARY`
ioquatix pushed a commit that referenced this pull request Jan 4, 2025
Marshal and JSON serialization are unavoidably different. A key
difference being that JSON serializes ruby symbols as strings, while
Marshal preserves them as symbols.

* Support UTF-8 data when using the JSON serializer
* Replace all instance of 'BINARY' with `Encoding::BINARY`
@jcmfernandes

Copy link
Copy Markdown
Contributor Author

ioquatix pushed a commit that referenced this pull request May 6, 2025
Marshal and JSON serialization are unavoidably different. A key
difference being that JSON serializes ruby symbols as strings, while
Marshal preserves them as symbols.

* Support UTF-8 data when using the JSON serializer
* Replace all instance of 'BINARY' with `Encoding::BINARY`
ioquatix pushed a commit that referenced this pull request May 9, 2025
Marshal and JSON serialization are unavoidably different. A key
difference being that JSON serializes ruby symbols as strings, while
Marshal preserves them as symbols.

* Support UTF-8 data when using the JSON serializer
* Replace all instance of 'BINARY' with `Encoding::BINARY`
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.

2 participants