Skip to content

Commit bbe2e00

Browse files
Merge pull request #888 from Muuhh-CTJ/jp-translation-oob1
Japanese translation of oob1
2 parents 5f45282 + 9d3b574 commit bbe2e00

File tree

2 files changed

+273
-0
lines changed

2 files changed

+273
-0
lines changed

docs/labs/ja_oob1.html

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
7+
<link rel="stylesheet" href="checker.css">
8+
<script src="checker.js"></script>
9+
<script src="oob1.js"></script>
10+
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
11+
12+
<!-- See create_labs.md for how to create your own lab! -->
13+
14+
</head>
15+
<body>
16+
<!-- For GitHub Pages formatting: -->
17+
<div class="container-lg px-3 my-5 markdown-body">
18+
<h1>ラボ演習 oob1</h1>
19+
<p>
20+
これはセキュアなソフトウェア開発に関するラボ演習です。
21+
ラボの詳細については、<a href="introduction.html" target="_blank">概要</a>をご覧ください。
22+
23+
<p>
24+
<h2>タスク</h2>
25+
<p>
26+
<b>バッファオーバーリードバグの一例として、OpenSSL の "Heartbleed" を単純化した以下のコードを変更してバグを修正してください</b>
27+
28+
<p>
29+
<h2>背景</h2>
30+
<p>
31+
ほとんど全てのプログラミング言語では、もしプログラムがバッファの外側を読み書きしようとした場合にはバッファをリサイズするか、何等かのエラーを出力するかをデフォルトの挙動としています(例:例外を上げる)。
32+
なぜなら誤ってバッファの外側を読み書きしようとするのは非常によくあることだからです。
33+
34+
<p>
35+
しかし、C と C++ は事情が異なります。
36+
C++ は進歩しており、いくらかは安全になっていますが(例:スマートポインタ)、
37+
C と C++ においてバッファの外側を読み書きするような動作は多くの場合で
38+
<i>未定義の動作</i>であり、未定義の動作に対しては
39+
<i>あらゆることが</i>
40+
なんの防御もなしに発生することになります。
41+
実際によく起こるのは、なにか他のデータが読み書きされることです。
42+
<a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2771r0.html"
43+
>proposals to improve C++ memory safety</a>
44+
という提案もありますが、現状では多くの C++ 組込みデータ構造(例えば配列)がメモリセーフではないため、ここでは二つの言語を同時に取り扱います。
45+
46+
<p>
47+
2014年に明らかになった Heartbleed(CVE-2014-0160)は、バッファオーバーリード脆弱性の一例です。
48+
Heartbleed は OpenSSL の脆弱性です。OpenSSL は暗号プロトコルである Secure Socket Layer (SSL) とその後継である Transport Layer Security (TLS) を C で実装しており、広く使用されているツールキットです。
49+
Heartbleed は極めて多くの、例えば
50+
Google, YouTube, Yahoo!, Pinterest, Blogspot, Instagram, Tumblr,
51+
Reddit, Netflix, Stack Overflow, Slate, GitHub, Yelp, Etsy, the
52+
U.S. Postal Service (USPS), Blogger, Dropbox, Wikipedia, and the
53+
Washington Post
54+
といった有名なウェブサイトに影響を与えました。
55+
より詳しくは <a href="https://dwheeler.com/essays/heartbleed.html">こちら</a> を参照してください。
56+
57+
58+
<p>
59+
<h2>タスクの詳細</h2>
60+
<p>
61+
ここでは OpenSSL の Heartbleed 脆弱性に対する修正を、<tt>dtls1_process_heartbeat</tt> という関数を修正することで再現します。
62+
63+
<p>
64+
この時点のコードでは、
65+
<tt>s->s3->rrec.length</tt>
66+
というデータ構造はバッファの何バイトが利用可能かを表します。
67+
もし上限サイズを確認しなければ、バッファを超えた読み出しが簡単に発生してしまいます。
68+
以下のコードでは2か所を変更することで、この問題を修正しましょう。
69+
70+
<p>
71+
まず初めに、レスポンスの最短の長さである <tt>(1 + 2 + 16)</tt>
72+
<tt>s->s3->rrec.length</tt>
73+
で取得できる長さを超えていればハートビートを送信せずに 0 を返すようにコードを変更します。
74+
これは、ハートビートを生成するための領域が全くない場合にはハートビートを生成しないようにするための措置です。
75+
76+
<p>
77+
続いて、ペイロードがある場合のレスポンスの最短の長さである
78+
<tt>(1 + 2 + payload + 16)</tt>
79+
が、
80+
<tt>s->s3->rrec.length</tt>
81+
で示されるレスポンスを格納するための領域より長い場合にも、ハートビートを送信せずに 0 を返すようコードを変更します。
82+
83+
<p>
84+
これにより、ハートビートそのものとペイロードがあるハートビートへの返信を格納するための領域がない場合にハートビートを作成しようとするのを防ぐことができます。
85+
86+
<p>
87+
これはそれほど難しい修正ではありません。
88+
ここではほんの短いコードを追加します。
89+
問題は、バッファの読み書きという非常に一般的な動作に対して、C と C++ はデフォルトでは安全ではないということです。
90+
実際には、全ての範囲の全ての可能性のあるケースを<i>常に</i>チェックするというのは困難です。これが、C または C++ で書かれたプログラムでメモリ安全性に関わる脆弱性がよく見られることの理由です。
91+
<!--
92+
if (1 + 2 + 16 > s->s3->rrec.length)
93+
return 0; /* silently discard */
94+
-->
95+
96+
<p>
97+
必要に応じて「ヒント」と「諦める」のボタンを使用してください。
98+
99+
<p>
100+
<h2>演習 (<span id="grade"></span>)</h2>
101+
<p>
102+
<form id="lab">
103+
<pre><code
104+
>int
105+
dtls1_process_heartbeat(SSL *s)
106+
{
107+
unsigned char *p = &s->s3->rrec.data[0], *pl;
108+
unsigned short hbtype;
109+
unsigned int payload;
110+
111+
// ... いくつかの詳細はここでは省略しています
112+
<textarea id="attempt0" rows="3" cols="60" spellcheck="false">
113+
if ()
114+
;
115+
</textarea>
116+
hbtype = *p++;
117+
n2s(p, payload);
118+
<textarea id="attempt1" rows="3" cols="60" spellcheck="false">
119+
if ()
120+
;
121+
</textarea>
122+
// ... 後ほど memcpy でペイロードデータを新しいバッファにコピーします
123+
// もしチェックしなければ、十分な領域がないかもしれません
124+
// memcpy(bp, pl, payload);
125+
</code></pre>
126+
<button type="button" class="hintButton">ヒント</button>
127+
<button type="button" class="resetButton">リセット</button>
128+
<button type="button" class="giveUpButton">諦める</button>
129+
<br><br>
130+
<p>
131+
<i>このラボは、<a href="https://www.linuxfoundation.org/">Linux Foundation</a>のDavid A. Wheelerによって開発されました。</i>
132+
<br><br>
133+
<p>
134+
135+
<details>
136+
<summary>引用元: ここに示した例は、<a href="https://github.com/openssl/openssl/blob/731f431497f463f3a2a97236fe0187b11c44aead/ssl/d1_both.c">OpenSSL のファイル <tt>ssl/d1_both.c</tt>
137+
commit 731f431497f4</a> から引用しました。ファイルのヘッダ部分はここを展開することで参照できます。</summary>
138+
<pre>
139+
/* ssl/d1_both.c */
140+
/*
141+
* DTLS implementation written by Nagendra Modadugu
142+
* ([email protected]) for the OpenSSL project 2005.
143+
*/
144+
/* ====================================================================
145+
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
146+
*
147+
* Redistribution and use in source and binary forms, with or without
148+
* modification, are permitted provided that the following conditions
149+
* are met:
150+
*
151+
* 1. Redistributions of source code must retain the above copyright
152+
* notice, this list of conditions and the following disclaimer.
153+
*
154+
* 2. Redistributions in binary form must reproduce the above copyright
155+
* notice, this list of conditions and the following disclaimer in
156+
* the documentation and/or other materials provided with the
157+
* distribution.
158+
*
159+
* 3. All advertising materials mentioning features or use of this
160+
* software must display the following acknowledgment:
161+
* "This product includes software developed by the OpenSSL Project
162+
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
163+
*
164+
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
165+
* endorse or promote products derived from this software without
166+
* prior written permission. For written permission, please contact
167+
168+
*
169+
* 5. Products derived from this software may not be called "OpenSSL"
170+
* nor may "OpenSSL" appear in their names without prior written
171+
* permission of the OpenSSL Project.
172+
*
173+
* 6. Redistributions of any form whatsoever must retain the following
174+
* acknowledgment:
175+
* "This product includes software developed by the OpenSSL Project
176+
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
177+
*
178+
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
179+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
180+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
181+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
182+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
183+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
184+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
185+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
186+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
187+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
188+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
189+
* OF THE POSSIBILITY OF SUCH DAMAGE.
190+
* ====================================================================
191+
*
192+
* This product includes cryptographic software written by Eric Young
193+
* ([email protected]). This product includes software written by Tim
194+
* Hudson ([email protected]).
195+
*
196+
*/
197+
/* Copyright (C) 1995-1998 Eric Young ([email protected])
198+
* All rights reserved.
199+
*
200+
* This package is an SSL implementation written
201+
* by Eric Young ([email protected]).
202+
* The implementation was written so as to conform with Netscapes SSL.
203+
*
204+
* This library is free for commercial and non-commercial use as long as
205+
* the following conditions are aheared to. The following conditions
206+
* apply to all code found in this distribution, be it the RC4, RSA,
207+
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
208+
* included with this distribution is covered by the same copyright terms
209+
* except that the holder is Tim Hudson ([email protected]).
210+
*
211+
* Copyright remains Eric Young's, and as such any Copyright notices in
212+
* the code are not to be removed.
213+
* If this package is used in a product, Eric Young should be given attribution
214+
* as the author of the parts of the library used.
215+
* This can be in the form of a textual message at program startup or
216+
* in documentation (online or textual) provided with the package.
217+
*
218+
* Redistribution and use in source and binary forms, with or without
219+
* modification, are permitted provided that the following conditions
220+
* are met:
221+
* 1. Redistributions of source code must retain the copyright
222+
* notice, this list of conditions and the following disclaimer.
223+
* 2. Redistributions in binary form must reproduce the above copyright
224+
* notice, this list of conditions and the following disclaimer in the
225+
* documentation and/or other materials provided with the distribution.
226+
* 3. All advertising materials mentioning features or use of this software
227+
* must display the following acknowledgement:
228+
* "This product includes cryptographic software written by
229+
* Eric Young ([email protected])"
230+
* The word 'cryptographic' can be left out if the rouines from the library
231+
* being used are not cryptographic related :-).
232+
* 4. If you include any Windows specific code (or a derivative thereof) from
233+
* the apps directory (application code) you must include an acknowledgement:
234+
* "This product includes software written by Tim Hudson ([email protected])"
235+
*
236+
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
237+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
238+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
239+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
240+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
243+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
244+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
245+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
246+
* SUCH DAMAGE.
247+
*
248+
* The licence and distribution terms for any publically available version or
249+
* derivative of this code cannot be changed. i.e. this code cannot simply be
250+
* copied and put under another distribution licence
251+
* [including the GNU Public Licence.]
252+
*/
253+
</pre>
254+
</details>
255+
<br><br>
256+
<p id="correctStamp" class="small">
257+
<textarea id="debugData" class="displayNone" rows="20" cols="65" readonly>
258+
</textarea>
259+
</form>
260+
</div><!-- End GitHub pages formatting -->
261+
</body>
262+
</html>

docs/labs/oob1.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,74 @@ info =
77
{
88
absent: "^ if",
99
text: "Begin with \"if\" as we will return 0 when there is a problem.",
10+
text_ja: "問題があれば 0 を返せるように \"if\" で始めてください。",
1011
examples: [
1112
[ " foo " ],
1213
],
1314
},
1415
{
1516
absent: String.raw`\(.*\)`,
1617
text: "Need \"(...)\" around the condition after an if statement.",
18+
text_ja: "if のあとの条件は (...) で囲む必要があります。",
1719
examples: [
1820
[ " if " ],
1921
],
2022
},
2123
{
2224
absent: "[<>]",
2325
text: "Need comparison \"if ( ... > ....)\"",
26+
text_ja: "\"if ( ... > ....)\" のような比較が必要です。",
2427
examples: [
2528
[ " if ( x )" ],
2629
],
2730
},
2831
{
2932
absent: String.raw`s -> s3 -> rrec \. length`,
3033
text: "Need to compare a value with s->s3->rrec.length",
34+
text_ja: "値を s->s3->rrec.length と比較する必要があります。",
3135
examples: [
3236
[ " if ( length > 3 )" ],
3337
],
3438
},
3539
{
3640
absent: "return 0 ;",
3741
text: "Need \"return 0;\" to skip attempts to send a too-long response.",
42+
text_ja: "長すぎるレスポンスが送信されないように \"return 0;\" が必要です。",
3843
},
3944
{
4045
absent: "^ if",
4146
text: "Begin with \"if\" as we will return 0 when there is a problem.",
47+
text_ja: "問題があれば 0 を返せるように \"if\" で始めてください。",
4248
index: 1,
4349
},
4450
{
4551
absent: String.raw`\(.*\)`,
4652
text: "Need \"(...)\" around the condition after an if statement.",
53+
text_ja: "if のあとの条件は (...) で囲む必要があります。",
4754
index: 1,
4855
},
4956
{
5057
absent: "[<>]",
5158
text: "Need comparison \"if ( ... > ....)\"",
59+
text_ja: "\"if ( ... > ....)\" のような比較が必要です。",
5260
index: 1,
5361
},
5462
{
5563
absent: String.raw`s -> s3 -> rrec \. length`,
5664
text: "Need to compare a value with s->s3->rrec.length",
65+
text_ja: "値を s->s3->rrec.length と比較する必要があります。",
5766
index: 1,
5867
},
5968
{
6069
absent: "return 0 ;",
6170
text: "Need \"return 0;\" to skip attempts to send a too-long response.",
71+
text_ja: "長すぎるレスポンスが送信されないように \"return 0;\" が必要です。",
6272
index: 1,
6373
},
6474
{
6575
absent: "payload",
6676
text: "Need to consider the payload length.",
77+
text_ja: "ペイロードの長さも考慮に入れてください。",
6778
index: 1,
6879
},
6980
],

0 commit comments

Comments
 (0)