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
*`message`: The message you want to display if the object gets passed to a Client Component. This message will be displayed as a part of the Error that will be thrown if the object gets passed to a Client Component.
*`object`: The object to be tainted. Functions and class instances can be passed to `taintObjectReference`as`object`. Functions and classes are already blocked from being passed to Client Components but the React's default error message will be replaced by what you defined in `message`. When a specific instance of a Typed Array is passed to `taintObjectReference`as`object`, any other copies of the Typed Array will not be tainted.
-Recreating or cloning a tainted object creates a new untainted object which may contain sensitive data. For example, if you have a tainted `user`object, `const userInfo = {name: user.name, ssn: user.ssn}`or`{...user}`will create new objects which are not tainted. `taintObjectReference`only protects against simple mistakes when the object is passed through to a Client Component unchanged.
**Do not rely on just tainting for security.** Tainting an object doesn't prevent leaking of every possible derived value. For example, the clone of a tainted object will create a new untainted object. Using data from a tainted object (e.g. `{secret: taintedObj.secret}`) will create a new value or object that is not tainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
A Client Component should never accept objects that carry sensitive data. Ideally, the data fetching functions should not expose data that the current user should not have access to. Sometimes mistakes happen during refactoring. To protect against these mistakes happening down the line we can "taint" the user object in our data API.
82
+
Client Component は、機密データを持つオブジェクトを決して受け取るべきではありません。理想的には、データ取得関数は現在のユーザに見せるべきではないデータを公開しないようにするべきです。しかしリファクタリング中にミスが起きることもあります。後続の処理でそのようなミスが起きた場合に備えて、データ API 内で `user` オブジェクトを「taint」できます。
If you're running a Server Components environment that has access to sensitive data, you have to be careful not to pass objects straight through:
104
+
機密データにアクセスできる Server Components 環境を実行している場合、オブジェクトをそのまま渡さないように注意する必要があります。
105
105
106
106
```js
107
107
// api.js
@@ -131,7 +131,7 @@ export async function InfoCard({ user }) {
131
131
}
132
132
```
133
133
134
-
Ideally, the `getUser`should not expose data that the current user should not have access to. To prevent passing the `user`object to a Client Component down the line we can "taint" the user object:
0 commit comments