You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/security.md
+37-37
Original file line number
Diff line number
Diff line change
@@ -1,122 +1,122 @@
1
-
# Security
1
+
# セキュリティ
2
2
3
-
## Reporting Vulnerabilities
3
+
## 脆弱性の報告
4
4
5
-
When a vulnerability is reported, it immediately becomes our top concern, with a full-time contributor dropping everything to work on it. To report a vulnerability, please email [[email protected]](mailto:[email protected]).
While the discovery of new vulnerabilities is rare, we also recommend always using the latest versions of Vue and its official companion libraries to ensure your application remains as secure as possible.
The most fundamental security rule when using Vue is**never use non-trusted content as your component template**. Doing so is equivalent to allowing arbitrary JavaScript execution in your application - and worse, could lead to server breaches if the code is executed during server-side rendering. An example of such usage:
Vue templates are compiled into JavaScript, and expressions inside templates will be executed as part of the rendering process. Although the expressions are evaluated against a specific rendering context, due to the complexity of potential global execution environments, it is impractical for a framework like Vue to completely shield you from potential malicious code execution without incurring unrealistic performance overhead. The most straightforward way to avoid this category of problems altogether is to make sure the contents of your Vue templates are always trusted and entirely controlled by you.
thus preventing the script injection. This escaping is done using native browser APIs, like `textContent`, so a vulnerability can only exist if the browser itself is vulnerable.
43
+
これにより、スクリプトの注入を防ぐことができます。このエスケープは、`textContent` のようなブラウザのネイティブ API を使って行われるため、ブラウザ自体に脆弱性がある場合にのみ脆弱性が存在します。
44
44
45
-
### Attribute bindings
45
+
### 属性の束縛
46
46
47
-
Similarly, dynamic attribute bindings are also automatically escaped. That means in this template:
47
+
同じように、動的な属性の束縛も自動的にエスケープされます。つまり、このテンプレートでは:
48
48
49
49
```html
50
50
<h1:title="userProvidedString">
51
51
hello
52
52
</h1>
53
53
```
54
54
55
-
if `userProvidedString`contained:
55
+
`userProvidedString`が含まれている場合:
56
56
57
57
```js
58
58
'" onclick="alert(\'hi\')'
59
59
```
60
60
61
-
then it would be escaped to the following HTML:
61
+
これは次のような HTML にエスケープされます:
62
62
63
63
```html
64
64
" onclick="alert('hi')
65
65
```
66
66
67
-
thus preventing the close of the `title`attribute to inject new, arbitrary HTML. This escaping is done using native browser APIs, like `setAttribute`, so a vulnerability can only exist if the browser itself is vulnerable.
67
+
これにより、新しい任意の HTML を注入するために `title`属性を閉じることができなくなります。このエスケープは、`setAttribute` のようなブラウザのネイティブ API を使って行われるため、ブラウザ自体に脆弱性がある場合にのみ脆弱性が存在します。
68
68
69
-
## Potential Dangers
69
+
## 潜在的な危険性
70
70
71
-
In any web application, allowing unsanitized, user-provided content to be executed as HTML, CSS, or JavaScript is potentially dangerous, so should be avoided wherever possible. There are times when some risk may be acceptable though.
For example, services like CodePen and JSFiddle allow user-provided content to be executed, but it's in a context where this is expected and sandboxed to some extent inside iframes. In the cases when an important feature inherently requires some level of vulnerability, it's up to your team to weigh the importance of the feature against the worst-case scenarios the vulnerability enables.
As you learned earlier, Vue automatically escapes HTML content, preventing you from accidentally injecting executable HTML into your application. However, in cases where you know the HTML is safe, you can explicitly render HTML content:
77
+
以前学んだように、Vue は自動的に HTML コンテンツをエスケープして、あなたのアプリケーション内で実行可能な HTML を誤って注入してしまうことを防ぎます。しかし、HTML が安全だとわかっている場合には、HTML コンテンツを明示的にレンダリングすることができます:
78
78
79
-
-Using a template:
79
+
-テンプレートを利用:
80
80
81
81
```html
82
82
<divv-html="userProvidedHtml"></div>
83
83
```
84
84
85
-
-Using a render function:
85
+
-Render 関数を利用:
86
86
87
87
```js
88
88
h('div', {
89
89
innerHTML:this.userProvidedHtml
90
90
})
91
91
```
92
92
93
-
-Using a render function with JSX:
93
+
-JSX と Render 関数を利用:
94
94
95
95
```jsx
96
96
<div innerHTML={this.userProvidedHtml}></div>
97
97
```
98
98
99
99
:::tip
100
-
Note that user-provided HTML can never be considered 100% safe unless it's in a sandboxed iframe or in a part of the app where only the user who wrote that HTML can ever be exposed to it. Additionally, allowing users to write their own Vue templates brings similar dangers.
100
+
ユーザが提供した HTML は、サンドボックス化された iframe や、その HTML を書いたユーザだけがアクセスできるアプリケーションの一部に置かない限り、100% 安全とは言えないことにちゅうしてください。加えて、ユーザが独自の Vue テンプレートを書けるようにしても同様の危険があります。
101
101
:::
102
102
103
-
### Injecting URLs
103
+
### URL の注入
104
104
105
-
In a URL like this:
105
+
このような URL で:
106
106
107
107
```html
108
108
<a:href="userProvidedUrl">
109
109
click me
110
110
</a>
111
111
```
112
112
113
-
There's a potential security issue if the URL has not been "sanitized" to prevent JavaScript execution using `javascript:`. There are libraries such as [sanitize-url](https://www.npmjs.com/package/@braintree/sanitize-url)to help with this, but note:
If you're ever doing URL sanitization on the frontend, you already have a security issue. User-provided URLs should always be sanitized by your backend before even being saved to a database. Then the problem is avoided for _every_ client connecting to your API, including native mobile apps. Also note that even with sanitized URLs, Vue cannot help you guarantee that they lead to safe destinations.
@@ -151,7 +151,7 @@ To keep your users fully safe from click jacking, we recommend only allowing ful
151
151
</a>
152
152
```
153
153
154
-
### Injecting JavaScript
154
+
### JavaScript の注入
155
155
156
156
We strongly discourage ever rendering a `<script>` element with Vue, since templates and render functions should never have side effects. However, this isn't the only way to include strings that would be evaluated as JavaScript at runtime.
157
157
@@ -167,7 +167,7 @@ Sometimes we receive vulnerability reports on how it's possible to do cross-site
167
167
168
168
2. The developer is mounting Vue to an entire HTML page which happens to contain server-rendered and user-provided content. This is fundamentally the same problem as \#1, but sometimes devs may do it without realizing. This can lead to possible vulnerabilities where the attacker provides HTML which is safe as plain HTML but unsafe as a Vue template. The best practice is to never mount Vue on nodes that may contain server-rendered and user-provided content.
169
169
170
-
## Best Practices
170
+
## ベストプラクティス
171
171
172
172
The general rule is that if you allow unsanitized, user-provided content to be executed (as either HTML, JavaScript, or even CSS), you might be opening yourself up to attacks. This advice actually holds true whether using Vue, another framework, or even no framework.
173
173
@@ -178,10 +178,10 @@ Beyond the recommendations made above for [Potential Dangers](#potential-dangers
178
178
179
179
Then use what you learn to also review the source code of your dependencies for potentially dangerous patterns, if any of them include 3rd-party components or otherwise influence what's rendered to the DOM.
180
180
181
-
## Backend Coordination
181
+
## バックエンドの調整
182
182
183
183
HTTP security vulnerabilities, such as cross-site request forgery (CSRF/XSRF) and cross-site script inclusion (XSSI), are primarily addressed on the backend, so aren't a concern of Vue's. However, it's still a good idea to communicate with your backend team to learn how to best interact with their API, e.g. by submitting CSRF tokens with form submissions.
184
184
185
-
## Server-Side Rendering (SSR)
185
+
## サーバサイドレンダリング(SSR)
186
186
187
187
There are some additional security concerns when using SSR, so make sure to follow the best practices outlined throughout [our SSR documentation](ssr/introduction.html) to avoid vulnerabilities.
0 commit comments