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
One of the things restricted by the `sandbox`attribute is navigation. A sandboxed iframe may not change`top.location`.
110
+
Однією з речей, обмежених атрибутом `sandbox`є навігація. Ізольований iframe може не змінювати`top.location`.
111
111
112
-
So we can add the iframe with `sandbox="allow-scripts allow-forms"`. That would relax the restrictions, permitting scripts and forms. But we omit`allow-top-navigation` so that changing`top.location` is forbidden.
112
+
Тож ми можемо додати iframe за допомогою `sandbox="allow-scripts allow-forms"`. Це послабить обмеження, дозволивши сценарії та форми. Але ми опускаємо`allow-top-navigation`, щоб заборонити зміну`top.location`.
There are other ways to work around that simple protection too.
120
+
Є й інші способи обходу цього простого захисту.
121
121
122
-
## X-Frame-Options
122
+
## Опції X-Frame
123
123
124
-
The server-side header `X-Frame-Options`can permit or forbid displaying the page inside a frame.
124
+
Заголовок на стороні сервера `X-Frame-Options`може дозволяти або забороняти відображення сторінки всередині фрейму.
125
125
126
-
It must be sent exactly as HTTP-header: the browser will ignore it if found in HTML `<meta>`tag. So, `<meta http-equiv="X-Frame-Options"...>`won't do anything.
126
+
Він має бути надісланий точно як HTTP-заголовок: браузер проігнорує його, якщо знайде в HTML `<meta>`тегу. Отже, `<meta http-equiv="X-Frame-Options"...>`нічого не дасть.
127
127
128
-
The header may have 3 values:
128
+
Заголовок може мати 3 значення:
129
129
130
130
131
131
`DENY`
132
-
: Never ever show the page inside a frame.
132
+
: Ніколи не показувати сторінку всередині фрейму.
133
133
134
134
`SAMEORIGIN`
135
-
: Allow inside a frame if the parent document comes from the same origin.
135
+
: Дозволити всередині фрейму, якщо батьківський документ походить із того самого джерела.
136
136
137
137
`ALLOW-FROM domain`
138
-
: Allow inside a frame if the parent document is from the given domain.
138
+
: Дозволити всередині фрейму, якщо батьківський документ із заданого домену.
139
139
140
-
For instance, Twitter uses`X-Frame-Options: SAMEORIGIN`.
140
+
Наприклад, Twitter використовує`X-Frame-Options: SAMEORIGIN`.
141
141
142
142
````online
143
-
Here's the result:
143
+
Ось результат:
144
144
145
145
```html
146
146
<iframe src="https://twitter.com"></iframe>
@@ -149,16 +149,16 @@ Here's the result:
149
149
<!-- ebook: prerender/ chrome headless dies and timeouts on this iframe -->
150
150
<iframe src="https://twitter.com"></iframe>
151
151
152
-
Depending on your browser, the `iframe` above is either empty or alerting you that the browser won't permit that page to be navigating in this way.
152
+
Залежно від вашого браузера, `iframe` вище або порожній, або попереджає вас про те, що браузер не дозволяє відобразити цю сторінку.
153
153
````
154
154
155
-
## Showing with disabled functionality
155
+
## Відображення з вимкненою функціональністю
156
156
157
-
The`X-Frame-Options`header has a side-effect. Other sites won't be able to show our page in a frame, even if they have good reasons to do so.
157
+
Заголовок`X-Frame-Options`має побічний ефект. Інші сайти не зможуть показати нашу сторінку у фреймі, навіть якщо у них є для цього вагомі причини.
158
158
159
-
So there are other solutions... For instance, we can "cover" the page with a `<div>`with styles`height: 100%; width: 100%;`, so that it will intercept all clicks. That`<div>`is to be removed if `window == top`or if we figure out that we don't need the protection.
159
+
Тому є інші рішення...Наприклад, ми можемо "покрити" сторінку `<div>`зі стилями`height: 100%; width: 100%;`, щоб він перехоплював усі клацання. Цей`<div>`можна видалити, якщо `window == top`або якщо ми зрозуміли, що захист нам не потрібен.
160
160
161
-
Something like this:
161
+
Щось на зразок цього:
162
162
163
163
```html
164
164
<style>
@@ -173,39 +173,39 @@ Something like this:
173
173
</style>
174
174
175
175
<divid="protector">
176
-
<ahref="/"target="_blank">Go to the site</a>
176
+
<ahref="/"target="_blank">Перейти на сайт</a>
177
177
</div>
178
178
179
179
<script>
180
-
//there will be an error if top window is from the different origin
181
-
//but that's ok here
180
+
//буде помилка, якщо верхнє вікно має інше походження
181
+
//але тут гаразд
182
182
if (top.document.domain==document.domain) {
183
183
protector.remove();
184
184
}
185
185
</script>
186
186
```
187
187
188
-
The demo:
188
+
Демо:
189
189
190
190
[codetabs src="protector"]
191
191
192
-
## Samesite cookie attribute
192
+
## Атрибут cookie: samesite
193
193
194
-
The `samesite`cookie attribute can also prevent clickjacking attacks.
194
+
Атрибут cookie `samesite`також може запобігти атакам клікджекінгу.
195
195
196
-
A cookie with such attribute is only sent to a website if it's opened directly, not via a frame, or otherwise. More information in the chapter<info:cookie#samesite>.
196
+
Файл cookie з таким атрибутом надсилається на веб-сайт, лише якщо його відкрито безпосередньо, а не через фрейм чи іншим чином. Більше інформації в розділі<info:cookie#samesite>.
197
197
198
-
If the site, such as Facebook, had `samesite`attribute on its authentication cookie, like this:
198
+
Якби сайт, наприклад Facebook, при аутентифікації мав атрибут `samesite`у файлі cookie , наприклад:
199
199
200
200
```
201
201
Set-Cookie: authorization=secret; samesite
202
202
```
203
203
204
-
...Then such cookie wouldn't be sent when Facebook is open in iframe from another site. So the attack would fail.
204
+
...Тоді такий файл cookie не надсилатиметься, коли Facebook буде відкрито в iframe з іншого сайту. Тож атака не вдасться.
205
205
206
-
The `samesite`cookie attribute will not have an effect when cookies are not used. This may allow other websites to easily show our public, unauthenticated pages in iframes.
206
+
Атрибут cookie `samesite`не матиме ефекту, якщо файли cookie не використовуються. Це може дозволити іншим веб-сайтам легко показувати наші загальнодоступні, неавтентифіковані сторінки в iframes.
207
207
208
-
However, this may also allow clickjacking attacks to work in a few limited cases. An anonymous polling website that prevents duplicate voting by checking IP addresses, for example, would still be vulnerable to clickjacking because it does not authenticate users using cookies.
208
+
Однак це також може дозволяти атакам за допомогою clickjacking працювати в кількох обмежених випадках. Наприклад, веб-сайт анонімного опитування, який запобігає дублюванню голосування шляхом перевірки IP-адреси, все одно буде вразливим до клікджекінгу, оскільки він не автентифікує користувачів за допомогою файлів cookie.
0 commit comments