Comments (2)
Source code disclosure using public directory middleware. Possible in express, restify, connect, koa etc if configured incorrectly.
Directory structure
- /fonts
- /images
- /scripts
- /stylesheets
- /index.html
- /app.js
app.js
var express = require('express');
var app = express();
// expose fonts, stylesheets etc to the front end
app.use(express.static(__dirname));
app.listen(1234);
Now the client side app can be loaded at http://localhost:3000
. Fonts and scripts can be referenced in index.html
using http://localhost:3000/fonts
or http://localhost:3000/scripts
. However, it also exposes sensitive files such as package.json
or app.js
(this file) or any other file in the app directory. Imagine things such as config files, model or controller code etc. Yikes!
from nodegoat.
Not sure what the theme of the application is but sensitive data exposure using cookies might be useful.
Simple - unencrypted cookies
var express = require('express');
var app = express();
app.use(express.cookieParser());
app.use(function(req, res) {
res.cookie('secret', 'data');
});
app.listen(1234);
Complex - Weak or default encryption passphrase
var express = require('express');
var app = express();
app.use(express.cookieParser('secret'));
app.use(function(req, res) {
// we've added a passphrase key but our cookie can still be cracked if the cookie data is relatively small
res.cookie('total_price', '100', { signed: true });
});
app.listen(1234);
We can crack the cookie since we know the HMAC algorithm (algorithm and key are prepended to the cookie value). Method: base64 decode, then use node crypto functions to crack the cookie and/or generate our own :). The key thing with this would be to ensure we use a simple cookie value such as a common password or a small integer.
It would be nice to include another gotcha somewhere around explicitly setting signed: true when creating the cookie if the cookie is secret. Otherwise, the cookie is not encrypted. Not a very safe default!
P.S I am just throwing ideas out there since I don't have access to Google Groups forum and dont know the process for getting stuff into the app. Happy to send pull requests as well.
from nodegoat.
Related Issues (20)
- Lerna Implementation
- React and Express API app
- Restore A9 Insecure Components vulnerability HOT 6
- There is no 404 page. HOT 3
- livereload.js making tests run slower HOT 2
- Webinterface: Wording HOT 1
- Heroku - mLab MongoDB Add-on Discontinued HOT 5
- docker_compose.yml doesn't set MONGODB_URI HOT 1
- Travis config warnings HOT 2
- NodeGoat Research page SSRF also enables DoS HOT 1
- purpleteam now at alpha HOT 2
- Unexpected path traversal vulnerability HOT 3
- A9 - Wrong url, to be removed HOT 1
- Broken XSS example
- Missing anchors in validation regular expression HOT 1
- Node Goat Herokuapp Application Error HOT 1
- Not working with MongoDB 5 HOT 4
- Setup Issue HOT 8
- Tutorial Guide page is not working HOT 4
- OpenAPI documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodegoat.