browserify / browserify/brfs

How do I restrict directory traversal?

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
556
Forks
58
PR merge metrics
No merged PRs in 30d

Description

brfs works great! I'm trying to use it in a CGI to re-invent browserify-as-a-service, but for this, it works too good. Suppose this `snoop.js` sneaks into one of my dependencies:

``` js
'use strict';
var fs = require('fs');
module.exports = {
powerState: fs.readFileSync('/sys/power/state', 'utf8'),
powerWakeupCount: fs.readFileSync('/sys/power/wakeup_count', 'utf8'),
installedDisks: fs.readdirSync('/dev/disk/by-id'),
ip4Devices: fs.readdirSync('/proc/sys/net/ipv4/conf'),
htpasswd: fs.readFileSync(__dirname + '/../../.git/.htpasswd', 'utf8'),
};
```

With just `brfs snoop.js`, it results in

``` js
'use strict';

module.exports = {
powerState: "freeze mem disk\n",
powerWakeupCount: "8\n",
installedDisks: ["ata-██MODEL██-██SERIAL██","ata-██MODEL██-██SERIAL██-part1","███[…]███"],
ip4Devices: ["all","default","eth█","lo","wlan█","█████","████"],
htpasswd: "# (fake logins, dont worry)\n# hax0r: notme\nhax0r:{SHA}30DQVTTQQ1u0WhIi1JAaDnqYDSc=\n# test: 321tset\ntest:{SHA}3s2ffDekAGYsJC59av3IisVQ3Is=\n",
};
```

So is there an easy way to specify a chroot-like path so that brfs will only read files within that path?

Update: Feature creep:
- array of whitelisted chdir paths
- custom decider function (or is this the tr.on(file) event?)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.