Skip to content
Misconfiguration Write-up Beginner

Identifying a PHPSESSID Cookie Security Misconfiguration on acr.iitbombay.org | Before & After Analysis

The PHP session cookie on the site was set without the HttpOnly attribute, so client-side JavaScript could read it. If malicious JavaScript ran on the origin, the session cookie could be exposed.

Praveen Rathod Follow

Published on medium.com

Cybersecurity

Praveen Rathod(Radhe_karn), on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

acr.iitbombay.org is a web application that uses PHP sessions. When a PHP application starts a session, the server sends the session identifier to the browser in a PHPSESSID cookie. The attributes on that cookie decide how the browser handles it: whether scripts can read it, whether it is sent over plain HTTP, and whether it is attached to cross-site requests.

This write-up covers a single finding from an assessment of that host: the PHPSESSID cookie was issued without the HttpOnly attribute. The author, Praveen Rathod (Radhe_Karn), frames the work around the idea that security research is not only about critical vulnerabilities, and that small misconfigurations reported responsibly can still matter.

Setup

No accounts, roles, tooling or versions are described. The assessment consisted of inspecting the server's HTTP response headers.

Finding it

While inspecting the response headers, the researcher noticed that the PHP session cookie was missing the HttpOnly security attribute. That attribute is what stops client-side JavaScript from reading document.cookie and lifting the session identifier. Without it, any script running in the origin can read the cookie value.

Exploitation

No exploitation was performed. The report states explicitly that no XSS exploitation, session hijacking or unauthorised access was attempted. What follows is the observed configuration and the recommended one.

Step 1: Observe the cookie as issued

The response header observed during the assessment:

HTTP
Set-Cookie: PHPSESSID=[REDACTED]; path=/

The cookie carries only a path attribute. There is no HttpOnly, so the value is readable from JavaScript. The session identifier itself is redacted here.

From the original on medium.com

Step 2: Note the consequence

Because the attribute is absent, client-side JavaScript can access the session cookie. The report describes this as potentially increasing session exposure if malicious JavaScript executes within the affected origin. The condition matters: the misconfiguration on its own does not hand anyone the session. It removes a defence that would otherwise limit the damage of script injection in that origin.

Step 3: Compare with the recommended header

The configuration the researcher recommends:

HTTP
Set-Cookie: PHPSESSID=[REDACTED]; Path=/; HttpOnly; Secure; SameSite=Lax
From the original on medium.com

The screenshot shows the recommended header configuration.

Each added attribute does a specific job:

  • HttpOnly prevents JavaScript access to the cookie.
  • Secure restricts cookie transmission to HTTPS.
  • SameSite=Lax provides additional protection against certain cross-site request risks.

Step 4: Record the details

The report summarises the finding as follows:

Field Value
Target acr.iitbombay.org
Affected cookie PHPSESSID
Vulnerability Missing HttpOnly attribute
CWE CWE-1004
Severity Low

Step 5: Report it

A technical report was prepared containing the affected URL, the HTTP response evidence, the potential impact and remediation recommendations, and it was sent to the concerned security/IT team for review.

From the original on medium.com

Root cause

The application sets the session cookie without the HttpOnly flag. The report does not show the configuration or code responsible, so the exact mechanism is not stated.

Impact

The severity is rated Low. The exposure is conditional: the cookie becomes reachable by an attacker only if malicious JavaScript runs in the affected origin, if malicious JavaScript executes within the affected origin. In that situation the missing attribute widens what a script can take, because the session identifier is readable rather than shielded. The report does not claim that any such script injection exists on the target, and no attempt was made to exploit the finding.

Fix

The report recommends the header shown above, adding HttpOnly, Secure and SameSite=Lax to the existing Path=/. It does not state that the configuration was changed on the live host; the recommendation is what should be applied. The three attributes together address script access, transmission over plain HTTP and some cross-site request risks.

Variants to test

  1. Check other session cookies on the same host, not just PHPSESSID. A positive result is any session cookie issued without HttpOnly.
  2. Check whether Secure is missing on cookies issued over HTTPS. A positive result is a session cookie that the browser would also send over plain HTTP.
  3. Check whether SameSite is absent or set to None without Secure. A positive result is a session cookie attached to cross-site requests.
  4. Check cookies set by JavaScript rather than by the server. A positive result is a session-relevant value written via document.cookie, which cannot carry HttpOnly at all.
  5. Repeat the header inspection after authentication and after privilege changes. A positive result is a session cookie reissued without the protective attributes at any of those points.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

What happened, in plain words

A security researcher looked at a website, acr.iitbombay.org, and noticed one small detail in how the site hands out a kind of digital name tag to visitors. That name tag is called a cookie, and the site was handing it out without one particular safety setting attached. The setting is called HttpOnly, and its job is to stop scripts running in the page from reading the name tag.

Nothing was broken into. No account was taken over. The researcher wrote down what was seen, suggested a better way to hand out the name tag, and sent the notes to the team that runs the site. The whole point of the article is that small configuration mistakes still deserve attention, and that reporting them politely is useful work.

To follow the rest of this article you only need to know how to open a website in a browser. Every technical word is explained where it first appears, and there is a glossary at the end.

About the author and the target

The author introduces himself as Praveen Rathod (Radhe_Karn), an independent security researcher who works on web application security and vulnerability research. He makes a point that security is not only about dramatic break-ins: finding a small misconfiguration and reporting it responsibly can still make a real difference.

The site he assessed is acr.iitbombay.org. The report does not describe what the site is for. PHP is a programming language commonly used to build websites; when a PHP site wants to remember who you are between page loads, it starts what is called a session.

A session is easiest to picture as a coat check. When you arrive, the cloakroom gives you a numbered ticket. On every later visit to the counter you show the ticket, and the staff fetch the coat that belongs to that number. The website does the same: when you log in or start using it, the server creates a session and gives your browser a long random string that identifies it. That string travels in a cookie called PHPSESSID.

1. The finding

The finding is stated in one line: the PHPSESSID cookie was missing the HttpOnly attribute.

A cookie is a small piece of text that a website asks your browser to store and to send back on later requests to that site. Cookies carry several optional settings, called attributes, which tell the browser how to treat them. HttpOnly is one of those settings. When it is present, the browser refuses to let JavaScript running in the page read that cookie. JavaScript is the programming language that makes web pages interactive, and it can read cookies through a built-in object called document.cookie unless a cookie is marked HttpOnly.

Why does that matter? Imagine your coat ticket were printed on a sticky note on your forehead instead of kept in your pocket. Anyone standing nearby, including someone who should not be there, could read the number. HttpOnly is the pocket: it keeps the ticket away from anything running inside the page.

The researcher found this by inspecting the server's HTTP response headers. A header is a line of extra information that travels with every web response, alongside the actual page content. You never see headers in the normal browser view.

2. Before: the configuration as observed

The report shows the header exactly as it was seen:

HTTP
Set-Cookie: PHPSESSID=[REDACTED]; path=/

Line by line, in plain words:

  • Set-Cookie: is the name of the header. It is how a server tells the browser, "please store this cookie".
  • PHPSESSID is the name of the cookie. It is the conventional name PHP uses for its session identifier.
  • [REDACTED] stands where the actual session value was. The real string is a secret, so it is hidden here; publishing it would be like printing your coat ticket number for everyone to see.
  • path=/ says the cookie applies to the whole site, from the top-level address downwards. The slash means the root of the site.

The observation is simple: the HttpOnly attribute was missing. Nothing else in that line shields the value from scripts.

From the original on medium.com

The report explains the consequence carefully. Because the attribute is absent, JavaScript running in the page can read the session cookie. That potentially increases how exposed the session is if malicious JavaScript ever runs within the affected origin. An origin, in browser terms, is the combination of scheme, host and port, for example https plus a hostname plus the default port; scripts from one origin are not supposed to reach into another. The word "potentially" matters: the missing setting on its own does not hand anyone your session. It removes a safety net that would otherwise limit the damage if a script injection flaw existed elsewhere on the site. A script injection flaw is a bug that lets an attacker get their own JavaScript to run inside someone else's page; the report does not claim that any such flaw exists on this site.

3. After: the recommended configuration

The researcher proposes a corrected header:

HTTP
Set-Cookie: PHPSESSID=[REDACTED]; Path=/; HttpOnly; Secure; SameSite=Lax

Line by line again:

  • Set-Cookie: and PHPSESSID are the same as before: the header that stores a cookie, and the name of the PHP session cookie.
  • [REDACTED] is again the hidden session value.
  • Path=/ keeps the cookie valid across the whole site, as before.
  • HttpOnly is the new safety setting: the browser will not let JavaScript read this cookie.
  • Secure tells the browser to send the cookie only over HTTPS, the encrypted version of web traffic. Picture sending a postcard versus a sealed letter: HTTPS is the sealed letter, and Secure says the ticket may only travel that way.
  • SameSite=Lax limits when the browser attaches the cookie to requests that start from a different website. It is a partial guard against certain cross-site request risks, meaning situations where another site causes your browser to make a request to this one.
From the original on medium.com

The screenshot shows the recommended header configuration.

The report lists the security improvements in the same terms: HttpOnly prevents JavaScript access to the cookie, Secure restricts cookie transmission to HTTPS, and SameSite=Lax provides additional protection against certain cross-site request risks.

4. The details, recorded in a table

The finding is summarised as follows:

Field Value
Target acr.iitbombay.org
Affected cookie PHPSESSID
Vulnerability Missing HttpOnly attribute
CWE CWE-1004
Severity Low

A few of those rows need unpacking. The target is simply the site that was assessed. The affected cookie is the one with the problem. The vulnerability is described in one phrase: the HttpOnly attribute was missing.

CWE stands for Common Weakness Enumeration, a public catalogue that gives standard numbers to kinds of software weakness so that different teams can refer to the same thing unambiguously. CWE-1004 is the catalogue entry for a cookie that is not marked HttpOnly. Think of it as a library shelf number for a particular kind of mistake.

Severity Low is the rating given in the report. Rating it Low is a judgement about how much damage it could contribute to, not a statement that it is harmless.

5. Responsible disclosure

After identifying the issue, the researcher prepared a technical report. That report contained the affected URL, the HTTP response evidence, the potential impact, and remediation recommendations. Remediation means the fix: what the site owners should change.

From the original on medium.com

The finding was then reported to the concerned security or IT team for review. The report states plainly that no XSS exploitation, session hijacking or unauthorised access was attempted. XSS, short for cross-site scripting, is the script injection flaw mentioned earlier; session hijacking means stealing someone's session ticket and using it as your own; unauthorised access means getting into something you were not allowed into. Responsible disclosure, the practice followed here, means telling the owners privately and giving them a chance to fix the problem rather than using it or publishing it carelessly.

6. Conclusion

The article closes on the idea that properly configuring session cookies strengthens web application security, and that even a small misconfiguration deserves attention when it can be addressed through responsible disclosure. The author sums up his approach in four words: identify, analyse, document, report responsibly.

Why this matters even though it is small

It is tempting to think a Low severity finding is not worth writing up. The value here is in the habit: look at how the site hands out its name tags, notice when a safety setting is absent, write down exactly what you saw, and tell the people who can fix it. The report does not say whether the site was changed afterwards; the recommendation is what should be applied.

Glossary

  • Attribute (of a cookie): an optional setting attached to a cookie that tells the browser how to handle it, such as HttpOnly, Secure or SameSite.
  • Cookie: a small piece of text a website asks the browser to store and send back on later requests to that site.
  • Cross-site request: a request your browser makes to one website because of something on a different website.
  • CWE: Common Weakness Enumeration, a public catalogue that assigns standard numbers to kinds of software weakness.
  • CWE-1004: the catalogue entry for a cookie that is not marked HttpOnly.
  • document.cookie: the built-in JavaScript object through which scripts can read and write cookies, except those marked HttpOnly.
  • Header: a line of extra information sent with a web request or response, separate from the page content itself.
  • HTTPS: the encrypted version of web traffic, where what travels between browser and server cannot be read in transit.
  • HttpOnly: a cookie attribute that stops JavaScript in the page from reading that cookie.
  • Intercepting proxy: a tool placed between browser and website that lets you read and modify the traffic.
  • JavaScript: the programming language that makes web pages interactive and that runs inside the browser.
  • Origin: the combination of scheme, host and port that a browser uses to decide which scripts may interact with which pages.
  • PHP: a programming language commonly used to build websites.
  • PHPSESSID: the conventional name of the cookie PHP uses to carry a session identifier.
  • Remediation: the fix; the change that removes the problem.
  • Responsible disclosure: reporting a security problem privately to the owners and giving them a chance to fix it before it is used or published.
  • SameSite=Lax: a cookie attribute that limits when the browser attaches the cookie to requests started from another site.
  • Secure: a cookie attribute that restricts the cookie to being sent only over HTTPS.
  • Severity: a rating of how much harm a finding could contribute to, here Low.
  • Session: a way for a website to remember who you are across multiple page loads.
  • Session hijacking: stealing someone's session identifier and using it to act as them.
  • Session identifier: the long random string that names a session, carried here in the PHPSESSID cookie.
  • XSS (cross-site scripting): a flaw that lets an attacker get their own JavaScript to run inside another person's page.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.