mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-11-02 02:55:40 +08:00
Merge pull request #182 from YukiOta/ja-trans/6.13
translate 6.13 into japanese
This commit is contained in:
@ -894,15 +894,15 @@ null == undefined; // true
|
||||
|
||||
<br/><br/>
|
||||
|
||||
## ![✔] 6.13. Run Node.js as non-root user
|
||||
## ![✔] 6.13. 非 root ユーザとして Node.js を実行する
|
||||
|
||||
<a href="https://www.owasp.org/index.php/Top_10-2017_A5-Broken_Access_Control" target="_blank"><img src="https://img.shields.io/badge/%E2%9C%94%20OWASP%20Threats%20-%20A5:Broken%20Access%20Access%20Control-green.svg" alt=""/></a>
|
||||
|
||||
**TL;DR:** There is a common scenario where Node.js runs as a root user with unlimited permissions. For example, this is the default behaviour in Docker containers. It's recommended to create a non-root user and either bake it into the Docker image (examples given below) or run the process on this user's behalf by invoking the container with the flag "-u username"
|
||||
**TL;DR:** Node.js が無制限の権限を持った root ユーザとして実行されるという一般的なシナリオがあります。例えば、Docker コンテナにおけるデフォルトの挙動です。root ではないユーザを作成して Docker イメージに組み込む(例は以下にあります)か、"-u username" フラグを利用してコンテナを起動することで、非 root ユーザでプロセスを実行することが推奨されます。
|
||||
|
||||
**Otherwise:** An attacker who manages to run a script on the server gets unlimited power over the local machine (e.g. change iptable and re-route traffic to his server)
|
||||
**さもないと:** サーバ上でスクリプトを実行することに成功した攻撃者が、ローカルマシンにおける無制限の権限を獲得してしまいます(例:iptable を変更して、攻撃者のサーバに再ルーティングする)。
|
||||
|
||||
🔗 [**Read More: Run Node.js as non-root user**](/sections/security/non-root-user.md)
|
||||
🔗 [**さらに読む: 非 root ユーザとして Node.js を実行する**](/sections/security/non-root-user.japanese.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
# Run Node.js as Non-Root User
|
||||
# 非 root ユーザとして Node.js を実行する
|
||||
|
||||
### One Paragraph Explainer
|
||||
### 一段落説明
|
||||
|
||||
According to the 'Principle of least privilege' a user/process must be able to access only the necessary information and resources. Granting root access to an attacker opens a whole new world of malicious ideas like routing traffic to other servers. In practice, most Node.js apps don't need root access and don't run with such privileges. However, there are two common scenarios that might push to root usage:
|
||||
「最小権限の原則」によれば、ユーザ/プロセスは必要な情報やリソースにだけアクセスできるようにしなければならない。攻撃者にルートアクセスを与えることは、他のサービスにトラフィックをルーティングしたりするような、ありとあらゆる悪意のあるアイデアを試せる環境を与えてしまうことになります。実際には、ほとんどの Node.js アプリケーションは root アクセスを必要とせず、そのような特権とともに実行することはありません。しかし、root ユーザを使わなければならない 2 つのシナリオがあります:
|
||||
|
||||
- to gain access to privilege port (e.g. port 80) Node.js must run as root
|
||||
- Docker containers by default run as root(!). It's recommended for Node.js web applications to listen on non-privileged ports and rely on a reverse-proxy like nginx to redirect incoming traffic from port 80 to your Node.js application. When building a Docker image, highly secured apps should run the container with an alternate non-root user. Most Docker clusters (e.g. Swarm, Kubernetes) allow setting the security context declaratively
|
||||
- 特権ポート(例:80番ポート)へのアクセスを得るために、Node.js を root として実行する
|
||||
- Docker コンテナはデフォルトで root として実行します(!)。Node.js ウェブアプリケーションは非特権ポートをリッスンし、受け付けるトラフィックを 80 番ポートから Node.js アプリケーションにリダイレクトするために nginx のようなリバースプロキシを利用することが推奨されます。Docker イメージをビルドする際は、安全性の高いアプリケーションは代理の非 root ユーザでコンテナを実行するべきです。多くの Docker クラスタ(例:Swarm、Kubernetes)は宣言的にセキュリティコンテクストを設定することが可能です。
|
||||
|
||||
### Code example - Building a Docker image as non-root
|
||||
### コード例 - 非 root ユーザとして Docker イメージを構築する
|
||||
|
||||
```dockerfile
|
||||
FROM node:latest
|
||||
@ -21,21 +21,21 @@ CMD ["node", "server.js"]
|
||||
|
||||
<br/><br/>
|
||||
|
||||
### Blog Quote: "By default, Docker runs container as root"
|
||||
### ブログ引用: "By default, Docker runs container as root"(デフォルトでは、Docker は root でコンテナを実行します)
|
||||
|
||||
From the Repository docker-node by [eyalzek](https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user):
|
||||
> By default, Docker runs container as root which inside of the container can pose as a security issue. You would want to run the container as an unprivileged user wherever possible. The node images provide the node user for such purpose. The Docker Image can then be run with the node user in the following way: "-u 'node'"
|
||||
[eyalzek](https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user) による docker-node リポジトリより:
|
||||
> デフォルトでは、Docker はコンテナを root で実行しますが、コンテナ内部ではセキュリティ上の問題が発生する可能性があります。可能な限り、非特権ユーザとしてコンテナを実行したいと思うでしょう。そのために、node イメージは node ユーザを提供しています。よって、Docker イメージは次のようにして node ユーザとして実行することができます: "-u 'node'"
|
||||
|
||||
<br/><br/>
|
||||
|
||||
### Blog Quote: "The attacker will have total control over your machine"
|
||||
### ブログ引用: "The attacker will have total control over your machine"(攻撃者はマシンのすべての権限を得るでしょう)
|
||||
|
||||
From the blog Don't run Node.js as root by [Olivier Lalonde](http://syskall.com/dont-run-node-dot-js-as-root/):
|
||||
> Indeed, if you are running your server as root and it gets hacked through a vulnerability in your code, the attacker will have total control over your machine. This means the attacker could potentially wipe out your whole disk or worse. On the other hand, if your server runs with the permissions of a regular user, the attacker will be limited by those permissions.
|
||||
[Olivier Lalonde](http://syskall.com/dont-run-node-dot-js-as-root/) のブログ Don't run Node.js as root より:
|
||||
> 実際、もし root でサーバを稼働させていて、コードの脆弱性からハッキングされた場合、攻撃者はマシンのすべての権限を得るでしょう。これは、潜在的に攻撃者がディスク全体を削除したり、さらに悪いことを行うことができるということを意味します。一方で、一般ユーザーの権限でサーバを実行していた場合、攻撃者はそれらの権限に制限されます。
|
||||
|
||||
<br/><br/>
|
||||
|
||||
### Blog Quote: "If you need to run your application on port 80 or 443, you can do port forwarding"
|
||||
### ブログ引用: "If you need to run your application on port 80 or 443, you can do port forwarding"(80 番ポートもしくは 443 番ポートでアプリケーションを実行する必要がある場合は、ポートフォワーディングが利用できます)
|
||||
|
||||
From the blog Developing Secure Node.js Applications — A Broad Guide by [Deepal Jayasekara](https://jsblog.insiderattack.net/developing-secure-node-js-applications-a-broad-guide-286afdec69ce):
|
||||
> Never run Node.js as root. Running node.js as root will make it worse if an attacker somehow gains control over your application. In this scenario, attacker would also gain root privileges which could result in a catastrophe. If you need to run your application on port 80 or 443, you can do port forwarding using iptables or you can place a front-end proxy such as nginx or apache which routes request from port 80 or 443 to your application
|
||||
[Deepal Jayasekara](https://jsblog.insiderattack.net/developing-secure-node-js-applications-a-broad-guide-286afdec69ce) によるブログ Developing Secure Node.js Applications — A Broad Guide より:
|
||||
> Node.js を絶対に root で実行しないでください。Node.js を root として実行すると、攻撃者が何らかの形でアプリケーションの制御権を得た場合に、最悪の事態を招くことになります。このシナリオでは、攻撃者は root 権限も取得してしまい、大惨事になる可能性があります。アプリケーションを 80 番や 443 番ポートで実行する必要がある場合には、iptables を利用してポートフォワーディングするか、nginx や apache のような、80 番 や 443 番ポートからアプリケーションへリクエストをルーティングしてくれるフロントエンドプロキシを配置してください。。
|
||||
|
||||
Reference in New Issue
Block a user