-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JS: Web Cache Deception Express #15180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
QHelp previews: javascript/ql/test/experimental/Security/CWE-525/WebCacheDeception.qhelpWeb Cache Deception in ExpressWeb Cache Deception is a security vulnerability where an attacker tricks a web server into caching sensitive information and then accesses that cached data. This attack exploits certain behaviors in caching mechanisms by requesting URLs that trick the server into thinking that a non-cachable page is cachable. If a user then accesses sensitive information on these pages, it could be cached and later retrieved by the attacker. RecommendationTo prevent Web Cache Deception attacks, web applications should clearly define cacheable and non-cacheable resources. Implementing strict cache controls and validating requested URLs can mitigate the risk of sensitive data being cached. ExampleVulnerable code example: A web server is configured to cache all responses ending in '.css'. An attacker requests 'profile.css', and the server processes 'profile', a sensitive page, and caches it. const express = require('express')
const app = express()
port = 3000
app.get('/test*', (req, res) => {
res.send('test')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
}) ExampleSecure code example: The server is configured with strict cache controls and URL validation, preventing caching of dynamic or sensitive pages regardless of their URL pattern. const express = require('express')
const app = express()
port = 3000
app.get('/test', (req, res) => {
res.send('test')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
}) References
|
Hello aydinnyunus 👋 In the meantime, feel free to make changes to the pull request. If you'd like to maximize payout for your this and future submissions, here are a few general guidelines, that we might take into consideration when reviewing a submission.
Please note that these are guidelines, not rules. Since we have a lot of different types of submissions, the guidelines might vary for each submission. Happy hacking! |
* @precision medium | ||
* @id js/web-cache-deception-express | ||
* @tags javascript | ||
* cwe-525 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag is wrong.
* cwe-525 | |
* external/cwe/cwe-525 |
* @precision medium | ||
* @id js/web-cache-deception-express | ||
* @tags javascript | ||
* cwe-525 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* cwe-525 | |
* external/cwe/cwe-525 |
</recommendation> | ||
<example> | ||
<p> | ||
Vulnerable code example: A web server is configured to cache all responses ending in '.css'. An attacker requests 'profile.css', and the server processes 'profile', a sensitive page, and caches it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where in the sample code is the "server is configured to cache all responses ending in '.css'."?
Pull Request: Add Web Cache Deception Query for CodeQL
Overview
This pull request introduces a new CodeQL query to detect potential Web Cache Deception vulnerabilities in web applications. Web Cache Deception is a security vulnerability where attackers trick a server into caching sensitive information, which they can later access. This query aims to identify code patterns that might make an application susceptible to this type of attack.
Changes Introduced
WebCacheDeception.ql
- Detects patterns where web applications might cache sensitive information inadvertently./CWE-525
directory, demonstrating both vulnerable (bad) and secure (good) coding practices related to caching.Implementation Details
Testing and Validation
Future Work
References