In node.js how would I follow the Principle of Least Privilege?

Imagine a web application that performs two main functions:

  1. Serves data from a file that requires higher privileges to read from
  2. Serves data from a file that requires lower privileges to read from

My Assumption: To allow both files to be read from, I would need to run node using an account that could read both files.

If node is running under an account that can access both files, then a user who should not be able to read any file that requires higher privileges could potentially read those files due to a security flaw in the web application's code. This would lead to disastrous consequences in my imaginary web application world.

Ideally the node process could run using a minimal set of rights and then temporarily escalate those rights before accessing a system resource.

Questions: Can node temporarily escalate privileges? Or is there a better way?

If not, I'm considering running two different servers (one with higher privileges and one with lower) and then putting them both behind a proxy server that authenticates/authorizes before forwarding the request.

Thanks.

8
задан Tim Stewart 15 May 2011 в 18:05
поделиться