Slide 1

Slide 1 text

ɹ!shin1x1 2016//03 PHPΧϯϑΝϨϯε ਖ਼نදݱ࠶ೖ໳

Slide 2

Slide 2 text

ৄࡉਖ਼نදݱ ਖ਼نදݱٕज़ೖ໳

Slide 3

Slide 3 text

D .BTBTIJ4IJOCBSB!TIJOY "HFOEB w1)1ͷਖ਼نදݱ wϚονϯά wόοΫτϥοΫ w3F%P4

Slide 4

Slide 4 text

1)1ͷਖ਼نදݱ

Slide 5

Slide 5 text

1)1ͷਖ਼نදݱ D .BTBTIJ4IJOCBSB!TIJOY w1$3&
 QSFHܥ w104*9ਖ਼نදݱ
 FSFHܥʢ1)1Ͱඇਪ঑ɺͰഇࢭʣ wَं
 NC@FSFHܥ

Slide 6

Slide 6 text

1)1ͷਖ਼نදݱ D .BTBTIJ4IJOCBSB!TIJOY w1$3&
 QSFHܥ w104*9ਖ਼نදݱ
 FSFHܥʢ1)1Ͱඇਪ঑ɺͰഇࢭʣ wَं
 NC@FSFHܥ

Slide 7

Slide 7 text

ਖ਼نදݱͷओͳར༻༻్ D .BTBTIJ4IJOCBSB!TIJOY wจࣈྻ͕Ϛον͢Δ͔Ͳ͏͔ͷ൑ผ wจࣈྻ͔ΒϚονͨ͠Օॴͷऔಘ wจࣈྻͷϚονͨ͠ՕॴΛஔ׵ wϚονͨ͠ՕॴͰจࣈྻΛ෼ׂ

Slide 8

Slide 8 text

ਖ਼نදݱͷओͳར༻༻్ D .BTBTIJ4IJOCBSB!TIJOY wϚον͢Δ͔Ͳ͏͔ͷ൑ผ wϚονͨ͠Օॴͷऔಘ
 QSFH@NBUDI QSFH@NBUDI@BMM QSFH@HSFQ wϚονͨ͠Օॴͷஔ׵
 QSFH@SFQMBDF QSFH@pMUFS wϚονͨ͠ՕॴͰจࣈྻΛ෼ׂ
 QSFH@TQMJU

Slide 9

Slide 9 text

Ϛονϯά

Slide 10

Slide 10 text

Ϛονϯάͷಛ௃ D .BTBTIJ4IJOCBSB!TIJOY wਖ਼نදݱ͸ؤுΓ԰ w࠷ॳʹϚονͨ͠΋ͷ͕༏ઌ wඪ४ͷྔࢦఆࢠ͸ཉுΓʢHSFFEZʣ

Slide 11

Slide 11 text

Ϛονϯάͷಛ௃ D .BTBTIJ4IJOCBSB!TIJOY wਖ਼نදݱ͸ؤுΓ԰ w࠷ॳʹϚονͨ͠΋ͷ͕༏ઌ wඪ४ͷྔࢦఆࢠ͸ཉுΓʢHSFFEZʣ ࠷௕࠷ࠨϚονϯά

Slide 12

Slide 12 text

ਖ਼نදݱ͸ؤுΓ԰ D .BTBTIJ4IJOCBSB!TIJOY wϚον͢Δ·ͰऔΓಘΔશͯͷύλʔϯΛࢼߦ
 Ϛον͢Ε͹ऴྃ wऔΓಘΔશͯͷύλʔϯ͕Ϛον͠ͳ͍
 Ϛονࣦഊ wϚονࣦഊͷ৔߹ɺॲཧྔ͕๲େʹͳΔՄೳੑ

Slide 13

Slide 13 text

B aE

Slide 14

Slide 14 text

B aE aEΛͰϚον

Slide 15

Slide 15 text

B aE ͱB͸Ϛον͠ͳ͍

Slide 16

Slide 16 text

B aE aEΛͰϚον όοΫτϥοΫ

Slide 17

Slide 17 text

B aE ͱ͸Ϛον͠ͳ͍

Slide 18

Slide 18 text

B aE จࣈྻΛਐΊͯ
 aEΛͰϚον

Slide 19

Slide 19 text

B aE ͱB͸Ϛον͠ͳ͍

Slide 20

Slide 20 text

B aE จࣈྻΛਐΊΔͱ
 aE͕Ϛον͢Δ΋ͷ͕ແ͍ Ϛονࣦഊ

Slide 21

Slide 21 text

࠷ॳʹϚονͨ͠΋ͷ͕༏ઌ D .BTBTIJ4IJOCBSB!TIJOY wจࣈྻ಺Ͱ࠷΋ࠨʹ͋ΔϚον͕༏ઌ
 ʢ࠷ॳʹϚονͨ͠Օॴʣ wਖ਼نදݱʢબ୒ʣͷฒͼͰ͸ͳ͍

Slide 22

Slide 22 text

1FO1JOFBQQMF"QQMF1FO

Slide 23

Slide 23 text

1FO1JOFBQQMF"QQMF1FO ?1FO Ϛον͢Δ

Slide 24

Slide 24 text

1FO1JOFBQQMF"QQMF1FO 1FO 1FO1JOFBQQMF"QQMF1FO

Slide 25

Slide 25 text

1FO1JOFBQQMF"QQMF1FO 1FO จࣈྻͷࠨଆͰϚονͨ͠΋ͷ͕༏ઌ ʢ্ͷύλʔϯͰऴྃʣ 1FO1JOFBQQMF"QQMF1FO

Slide 26

Slide 26 text

1FO1JOFBQQMF"QQMF1FO "QQMFc1FO

Slide 27

Slide 27 text

1FO1JOFBQQMF"QQMF1FO "QQMFc1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO

Slide 28

Slide 28 text

1FO1JOFBQQMF"QQMF1FO "QQMFc1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO จࣈྻͷࠨଆͰϚονͨ͠΋ͷ͕༏ઌ

Slide 29

Slide 29 text

ඪ४ͷྔࢦఆࢠ͸ཉுΓ D .BTBTIJ4IJOCBSB!TIJOY wඪ४ͷྔࢦఆࢠ͸ɺ࠷௕ʹϚον wσϑΥϧτͰ͸࠷େྔࢦఆࢠͱͯ͠ಈ͘

Slide 30

Slide 30 text

ྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY w௚લͷύλʔϯͷ܁Γฦ͠Λࣔ͢ wɺɺ ɺ\O N^ wBͳΒʮBʯʮBBCʯʮDBBBBCʯͳͲʹϚον

Slide 31

Slide 31 text

1FO1JOFBQQMF"QQMF1FO 1O ճҎ্

Slide 32

Slide 32 text

1FO1JOFBQQMF"QQMF1FO 1O 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO

Slide 33

Slide 33 text

1FO1JOFBQQMF"QQMF1FO 1O ඪ४ͷྔࢦఆࢠ͸࠷௕ͰϚον

Slide 34

Slide 34 text

1FO1JOFBQQMF"QQMF1FO 1O ճҎ্

Slide 35

Slide 35 text

1FO1JOFBQQMF"QQMF1FO 1 O ΋͘͠͸ճ 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO

Slide 36

Slide 36 text

1FO1JOFBQQMF"QQMF1FO 1 O ΋͘͠͸ճ 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO

Slide 37

Slide 37 text

1\ ^O ճҎ্ճҎԼ 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO

Slide 38

Slide 38 text

1\ ^O 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO 1FO1JOFBQQMF"QQMF1FO ճҎ্ճҎԼ

Slide 39

Slide 39 text

ྔࢦఆࢠͷϚονϯάύλʔϯ D .BTBTIJ4IJOCBSB!TIJOY w࠷େྔࢦఆࢠʢσϑΥϧτʣ w࠷খྔࢦఆࢠ wઈର࠷େྔࢦఆࢠ

Slide 40

Slide 40 text

࠷େྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY wྔࢦఆࢠσϑΥϧτͷಈ͖ w \O N^ w࠷௕ʹϚονɺཉுΓͳϚον

Slide 41

Slide 41 text

࠷খྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY wྔࢦఆࢠʹ Λ෇͚ͯࢦఆ w ɺ ɺ ɺ\O N^ w࠷খͷϚονɺ߇͑ΊͳϚον

Slide 42

Slide 42 text

1FO1JOFBQQMF"QQMF1FO 1O ࠷௕ͰϚον

Slide 43

Slide 43 text

1FO1JOFBQQMF"QQMF1FO 1 O ࠷୹ͰϚον

Slide 44

Slide 44 text

GPPBOECBS GPPΛϚον͍ͨ͠

Slide 45

Slide 45 text

࠷େྔࢦఆࢠ GPPBOECBS

Slide 46

Slide 46 text

> Ҏ֎ͷ܁Γฦ͠ GPPBOECBS

Slide 47

Slide 47 text

࠷খྔࢦఆࢠ GPPBOECBS

Slide 48

Slide 48 text

࠷େྔࢦఆࢠͱ࠷খྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY w࠷େྔࢦఆࢠ࠷௕Ұக͔Βࢼߦ͍ͯ͘͠ w࠷খྔࢦఆࢠ࠷୹Ұக͔Βࢼߦ͍ͯ͘͠ wϚον͠ͳ͍৔߹ͲͪΒ΋ಉ͡ࢼߦΛߦ͏

Slide 49

Slide 49 text

ઈର࠷େྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY wྔࢦఆࢠʹΛ෇͚ͯࢦఆ wɺɺ ɺ\O N^ wڧཉͳϚονɺఘΊͳ͍Ϛον

Slide 50

Slide 50 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛονࣦഊ

Slide 51

Slide 51 text

όοΫτϥοΫ

Slide 52

Slide 52 text

όοΫτϥοΫ D .BTBTIJ4IJOCBSB!TIJOY wϚον͕ࣦഊͨ͠৔߹ʹ
 લͷਖ਼نදݱʹ໭ΓɺผͷϚονΛߦ͏ wਖ਼͍͠ղΛಘΔ·ͰՄೳͳ૊Έ߹ΘͤΛ
 ޮ཰తʹࢼ͍ͯ͘͠ https://ja.wikipedia.org/wiki/όοΫτϥοΩϯά

Slide 53

Slide 53 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ

Slide 54

Slide 54 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ

Slide 55

Slide 55 text

1FO1JOFBQQMF"QQMF1FO 1O Oͱߦ຤ͳͷͰ Ϛον͠ͳ͍

Slide 56

Slide 56 text

1FO1JOFBQQMF"QQMF1FO 1O จࣈ୹ͯ͘͠Ϛον όοΫτϥοΫ

Slide 57

Slide 57 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον੒ޭ

Slide 58

Slide 58 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ

Slide 59

Slide 59 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ Ϛονͨ͠ൣғΛΞτϛοΫʹѻ͏

Slide 60

Slide 60 text

1FO1JOFBQQMF"QQMF1FO 1O Oͱߦ຤ͳͷͰ Ϛον͠ͳ͍

Slide 61

Slide 61 text

1FO1JOFBQQMF"QQMF1FO 1O ͰϚονͨ͠Օॴͷ࠶୳ࠪ͸ߦΘͣɺ ਖ਼نදݱΛ1͔ΒϚον͠௚͢

Slide 62

Slide 62 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ Ϛονͨ͠ൣғΛΞτϛοΫʹѻ͏

Slide 63

Slide 63 text

1FO1JOFBQQMF"QQMF1FO 1O Oͱߦ຤ͳͷͰ Ϛον͠ͳ͍

Slide 64

Slide 64 text

1FO1JOFBQQMF"QQMF1FO 1O ͰϚονͨ͠Օॴͷ࠶୳ࠪ͸ߦΘͣɺ ਖ਼نදݱΛ1͔ΒϚον͠௚͢

Slide 65

Slide 65 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛον͢Δ Ϛονͨ͠ൣғΛΞτϛοΫʹѻ͏

Slide 66

Slide 66 text

1FO1JOFBQQMF"QQMF1FO 1O Oͱߦ຤ͳͷͰ Ϛον͠ͳ͍

Slide 67

Slide 67 text

1FO1JOFBQQMF"QQMF1FO 1O Ϛονࣦഊ

Slide 68

Slide 68 text

ઈର࠷େྔࢦఆࢠ D .BTBTIJ4IJOCBSB!TIJOY wҰ౓Ϛονϯάͨ͠ൣғΛΞτϛοΫʹѻ͍ɺ
 όοΫτϥοΫͰख์͞ͳ͍ wΞτϛοΫάϧʔϓͰ΋ಉ༷ͷޮՌ
 Ͱ΋ಉ༷ͷޮՌ wόοΫτϥοΫൃੜ਺Λ཈͑Δ

Slide 69

Slide 69 text

SFHVMBSFYQSFTTJPOT D .BTBTIJ4IJOCBSB!TIJOY https://regex101.com/

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

όοΫτϥοΫʹΑΔ %P4

Slide 72

Slide 72 text

http://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016

Slide 73

Slide 73 text

w4UBDL0WFSqPXͰ෼ؒΞΫηεෆೳ wจࣈྻલޙͷۭനΛ࡟আ͢Δਖ਼نදݱ w?c w ͷۭന຤ඌ͸ۭനҎ֎

Slide 74

Slide 74 text

ݕূ D .BTBTIJ4IJOCBSB!TIJOY wQSFH@SFQMBDF 1)1 w୯७Խͯ͠ɺaTͱaTͰݕূ w/ݸͷۭന`B`ʹରͯ͠ॲཧ

Slide 75

Slide 75 text

/TQBDFTB 1)1 1)1 NT NT NT NT NT NT NT NT QSFH@SFQMBDF aT

Slide 76

Slide 76 text

/TQBDFTB 1)1 1)1 NT NT NT NT NT NT NT
 aTൺ NT aTൺ QSFH@SFQMBDF aT

Slide 77

Slide 77 text

ରԠࡦ D .BTBTIJ4IJOCBSB!TIJOY wઈର࠷େྔࢦఆࢠͰόοΫτϥοΫΛ཈੍ wจࣈྻ௕ΛόϦσʔγϣϯͰ੍ݶ wਖ਼نදݱΛ࢖Θͳ͍
 4UBDL0WFSqPXͰͷରԠ
 จࣈྻؔ਺Ͱஔ׵͑

Slide 78

Slide 78 text

3F%P4

Slide 79

Slide 79 text

3F%P4 D .BTBTIJ4IJOCBSB!TIJOY wਖ਼نදݱΛѱ༻ͨ͠%P4 w೥͔Β໰୊ఏى͞Ε͍ͯͨ wϚον͠ͳ͍ύλʔϯͰ߈ܸ https://www.checkmarx.com/wp-content/uploads/2015/03/ReDoS-Attacks.pdf

Slide 80

Slide 80 text

https://www.checkmarx.com/wp-content/uploads/2015/03/ReDoS-Attacks.pdf

Slide 81

Slide 81 text

&WJM3FHFY1BUUFSOT D .BTBTIJ4IJOCBSB!TIJOY w B w w BcBB w BcB w B \Y^cGPSY

Slide 82

Slide 82 text

BBBBBBBBBBBBBBBBBBB9 B

Slide 83

Slide 83 text

TUFQT ࢀߟ յ໓తͳόοΫτϥοΫ B BBBBBBBBBBBBBBBBBBB9

Slide 84

Slide 84 text

&WJM3FHFY1BUUFSOT D .BTBTIJ4IJOCBSB!TIJOY wΘ͔ͣจࣈͷจࣈྻͰ΋
 ૊Έ߹Θͤരൃ͕ى͜Δ wྔࢦఆࢠͷೖΕࢠɺબ୒ͱྔࢦఆࢠͷೖΕࢠ

Slide 85

Slide 85 text

1)1Ͱ࣮ߦ D .BTBTIJ4IJOCBSB!TIJOY preg_match('/(a+)+$/', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaX'); 1)1 1)1 QSFH@NBUDI NT NT ଎͍ʂʂʂ

Slide 86

Slide 86 text

όοΫτϥοΫ੍ݶ D .BTBTIJ4IJOCBSB!TIJOY wઃఆʹΑΔόοΫτϥοΫ੍ݶ
 QDSFCBDLUSBDL@MJNJUʢσϑΥϧτ͸ ʣ w্ݶʹୡ͢ΔͱΤϥʔͰऴྃ wQSFH@NBUDI ͷ໭Γ஋͕GBMTF
 ΤϥʔΛࣔ͢ wQSFH@MBTU@FSSPS ͰΤϥʔίʔυऔಘ

Slide 87

Slide 87 text

1)1Ͱ࣮ߦ D .BTBTIJ4IJOCBSB!TIJOY 0) {
 echo 'other error', PHP_EOL;
 } $ php redos.php backtrack limit error

Slide 88

Slide 88 text

1)1Ͱ࣮ߦʢ੍ݶ֎͠ʣ D .BTBTIJ4IJOCBSB!TIJOY ini_set('pcre.backtrack_limit', 10000000000); preg_match('/(a+)+$/', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaX'); 1)1 1)1 QSFH@NBUDI NT NT ͕͔͔࣌ؒΔ

Slide 89

Slide 89 text

$47ͷύʔε D .BTBTIJ4IJOCBSB!TIJOY wਖ਼نදݱͰ࣮૷ w1P$ͳ$47Λύʔε͢Δͱ
 4FHNFOUBUJPO'BVMUʢ1)1ʣ wHPPECZDTWͰॻ͖௚ͯ͠ରԠ

Slide 90

Slide 90 text

·ͱΊ

Slide 91

Slide 91 text

·ͱΊ D .BTBTIJ4IJOCBSB!TIJOY wϚονϯάͷྲྀΕ wύϑΥʔϚϯε΁ͷӨڹ wਖ਼نදݱΛ͋͑ͯ࢖Θͳ͍બ୒ࢶ

Slide 92

Slide 92 text

ࢀߟ D .BTBTIJ4IJOCBSB!TIJOY w4UBDL&YDIBOHF͕߈ܸ͞Εͨ3F%P4ͷޮՌcZPIHBLJTCMPH
 IUUQTCMPHPIHBLJOFUTUBDLFYDIBOHFSFEPTBUUBDL w3F%P4ͷճආcZPIHBLJTCMPH
 IUUQTCMPHPIHBLJOFUBWPJEJOHSFEPT

Slide 93

Slide 93 text

D .BTBTIJ4IJOCBSB!TIJOY !TIJOY !TIJOY D .BTBTIJ4IJOCBSB!TIJOY