Make the session cookie unforgeable - #85
Merged
Merged
Conversation
The session cookie was a constant: any client that set M2MSESSIONID=1 was treated as logged in, bypassing the password entirely — including for OTA firmware upload. The cookie value is now MD5(client IP + login password), verified on every request, as suggested in the issue discussion. Also marks the cookie HttpOnly/SameSite=Strict and clears it properly on logout. Fixes floatplane#59 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
floatplane
approved these changes
Jul 27, 2026
floatplane
left a comment
Owner
There was a problem hiding this comment.
thank you for cleaning this up!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #59.
The session cookie was a constant — any client that set
M2MSESSIONID=1was treated as logged in, bypassing the password entirely, including for the OTA upload endpoints.This implements the approach suggested in the issue discussion: the cookie value is now
MD5(client IP + login password), recomputed and verified on every request viais_authenticated(). Properties:Also while touching these lines:
HttpOnly; SameSite=StrictMax-Age=0so the browser actually drops the cookieMD5Buildercomes from the Arduino core on both ESP8266 and ESP32, so no new dependencies. Clients on changing IPs (DHCP lease change) will need to log in again, which seems like the right trade-off for a device like this.Testing
pio test -e test-nativepasses;WEMOS_D1_Minibuilds clean;src/is clang-format-17 clean🤖 Generated with Claude Code