RDKB-65950 Fix HTTP login session cookie Secure flag handling#28
Open
pavankumar464 wants to merge 2 commits into
Open
RDKB-65950 Fix HTTP login session cookie Secure flag handling#28pavankumar464 wants to merge 2 commits into
pavankumar464 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes HTTP login session cookie Secure flag handling by introducing a helper to more accurately detect HTTPS requests and applying that logic when setting the DUKSID cookie.
Changes:
- Added
is_https_request()to interpret theHTTPSenvironment variable safely (e.g., only treatingon/1/trueas HTTPS). - Updated
session_start()andsession_create()to set the cookiesecureattribute only when the request is HTTPS.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+113
to
+116
| if (is_https_request()) | ||
| var $cookie = "Set-Cookie: DUKSID=" + ccsp_session.getId() + "; secure" + "; httponly"; | ||
| else | ||
| var $cookie = "Set-Cookie: DUKSID=" + ccsp_session.getId() + "; secure" + "; httponly"; | ||
| var $cookie = "Set-Cookie: DUKSID=" + ccsp_session.getId() + "; httponly"; |
Comment on lines
+140
to
+143
| if (is_https_request()) | ||
| var $cookie = "Set-Cookie: DUKSID=" + ccsp_session.getId() + "; secure" + "; httponly"; | ||
| else | ||
| var $cookie = "Set-Cookie: DUKSID=" + ccsp_session.getId() + "; httponly"; |
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.
Root Cause:
In jst_prefix.js where session cookie flags were decided by:
getenv('HTTPS') == false check (too loose / incorrect)
If CGI sets HTTPS=off on HTTP requests, that value is not boolean false, so code incorrectly treated it as HTTPS and emitted:
Set-Cookie: DUKSID=...; secure; httponly
Browsers won’t send a Secure cookie over plain HTTP, so next HTTP request has no valid DUKSID, and server sends you to logged out.
Fix: updated jst_prefix.js to use a strict helper:
is_https_request() returns true only for HTTPS values: on, 1, true (case-insensitive)
Secure is added only when truly HTTPS
Used in both session_start() and session_create()