Sensitive Cookie in HTTPS Session Without 'Secure' Attribute in khodakhah/nodcms

Valid

Reported on

Sep 26th 2021


Description
Implement both Secure flag and httponly flag in the application.

Proof of Concept

Impact
The secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP Response. 
The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text. To accomplish this goal, browsers which support the secure flag will only send cookies with the secure flag when the request is going to a HTTPS page. Said in another way, the browser will not send a cookie with the secure flag set over an unencrypted HTTP request. By setting the secure flag, the browser will prevent the transmission of a cookie over an unencrypted channel.

PoC Request

GET /en/login HTTP/1.1
Host: demo.nodcms.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Te: trailers
Connection: close

Response

HTTP/2 200 OK
Date: Sun, 26 Sep 2021 21:29:22 GMT
Server: Apache
X-Powered-By: PHP/7.2.34
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Cache-Control: no-store, max-age=0, no-cache
Set-Cookie: ci_session=483e0d04fcc809c07b21d95e3240499154eadafb; expires=Sun, 26-Sep-2021 23:29:22 GMT; Max-Age=7200; path=/; HttpOnly
Strict-Transport-Security: max-age=63072000; includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Vary: Accept-Encoding
Content-Length: 7396
Content-Type: text/html; charset=UTF-8

Solution:
if os.environ.get('SECURE_PROXY_SSL_HEADER'):
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
We have contacted a member of the khodakhah/nodcms team and are waiting to hear back 2 years ago
khodakhah validated this vulnerability 2 years ago
@0xAmal has been awarded the disclosure bounty
The fix bounty is now up for grabs
khodakhah marked this as fixed with commit ab89b0 2 years ago
The fix bounty has been dropped
This vulnerability will not receive a CVE
to join this conversation