ãã¹ãŠã®ã·ã¹ãã ïŒè€éã§ã¯ãªãïŒã¯ã倧éã®ããŒã¿ãšããŸããŸãªãªããžã§ã¯ããæ ŒçŽããŸãã ããšãã°ããŠãŒã¶ãŒã¢ã«ãŠã³ããã·ã¹ãã ã¢ã«ãŠã³ãããã©ã³ã¶ã¯ã·ã§ã³ããã©ã³ã¶ã¯ã·ã§ã³ãã°ãšã³ããªãªã©ã®ããžãã¹ããžãã¯ãªããžã§ã¯ãã
ãããã®ãªããžã§ã¯ãã«ã¢ã¯ã»ã¹ããããã«ãããããã®ãã©ãŒã ã¯ãäœããã®åœ¢ã§ç¬èªã®äžæã®èå¥åãæã£ãŠããŸãã ããã«ããªããžã§ã¯ãã«ã¯ä»»æã®ãã£ãŒã«ãã»ãããå«ããããšãã§ããŸãã ãã¹ãŠã®ãã£ãŒã«ãã«ã¯ãç¬èªã®äžæã®ååãŸãã¯èå¥åããããŸãã
ãããã ãã§ãªããããããã¹ãŠã®ãªããžã§ã¯ãã¯ãåè¡ã1ã€ã®ãªããžã§ã¯ãã§ããããŒãã«ã«æ ŒçŽãããŸãã
ããšãã°ãClientãªããžã§ã¯ãã«ã¯ãidãåãå§ãé»åã¡ãŒã«ãæºåž¯é»è©±ã®ãã£ãŒã«ãã»ãããããããã©ãŒã ã®ããŒãã«ã«ä¿åã§ããŸãã
ã¯ã©ã€ã¢ã³ãè¡š
id
ïŒèå¥åïŒ | cl_name
ïŒååïŒ | cl_sur_nameïŒå§ïŒ | é»åã¡ãŒã« | ã»ã«
ïŒã¢ãã€ã«ïŒ | ãã®ä»
ïŒãªã©ïŒ |
1 | ã€ã¯ã³ | ã€ã¯ãã | ivan @ mail | +70000000000 | 42 |
ãªããžã§ã¯ããåä¿¡ãŸãã¯å€æŽããã«ã¯ïŒããšãã°ãå£åº§æ现æžãåä¿¡ãããããããã¡ã€ã«ãæŽæ°ããããïŒããµãŒããŒäžã§ãã®ããŒãžãŸãã¯ãã®ããŒãžãèŠæ±ããå¿ èŠããããŸãïŒä»¥éãã¹ã¯ãªãããšåŒã³ãŸãïŒã ãã®ç®çã®ããã®Webã¢ããªã±ãŒã·ã§ã³ã¯ããã©ãŒã ã䜿çšããããã¹ã¯ãªããURLãçŽæ¥åŒã³åºããŸãã
ãã©ãŠã¶ãšãµãŒããŒã®éã§ããŒã¿ã亀æããããã«ãHTTPãããã³ã«ãéçºãããŸããã ããŒã¿ã¯ãããããHTTPãªã¯ãšã¹ãã®åœ¢åŒã§éä¿¡ãããåãªã¯ãšã¹ãã¯ããããŒãšãªã¯ãšã¹ãæ¬æã§æ§æãããŸãã
HTTPãããã³ã«ãä»ããŠãŠãŒã¶ãŒã®ãã©ãŠã¶ãŒãããµãŒããŒã«ããŒã¿ã転éããã«ã¯ãäž»ã«GETããã³POSTã®2ã€ã®ã¡ãœããã䜿çšãããŸãïŒPUTããã³DELETEã¡ãœããããããŸãããäž»ã«APIã§äœ¿çšãããŸãïŒã
GETã¡ãœããã䜿çšããŠããŒã¿ãéä¿¡ããå Žåããã¹ãŠã®ãªã¯ãšã¹ããã©ã¡ãŒã¿ã¯ãHTTPãªã¯ãšã¹ãã®ããããŒå ã®ããŒãžURLã«è»¢éãããŸãã次ã«äŸã瀺ããŸãã
http://simplethreats.ru/get_order?order=150
POSTã¡ãœããã䜿çšããå ŽåããµãŒããŒã¯HTTPãªã¯ãšã¹ãã®æ¬æã§æ¢ã«ããŒã¿ãåä¿¡ãããã©ã¡ãŒã¿ãŒã¯URLã«ãªã¹ããããŸããã ãããã£ãŠãããšãã°ãã»ãšãã©ã®ãã©ãŒã ãéä¿¡ãããåžžã«éèŠãªèªèšŒããŒã¿ãåžžã«éä¿¡ãããŸãïŒURLãšã³ããªãšHTTPãªã¯ãšã¹ãããããŒã¯å€ãã®ãã°ã«æ®ããããURLãžã®ããŒã¿éä¿¡ã¯å®å šã§ã¯ãããŸããïŒã
GETãŸãã¯POSTåŒã³åºãã¯ããªããžã§ã¯ããããŒã¿ããŒã¹å ã®ã¬ã³ãŒãã§ãããããã¡ã€ã«ïŒãã£ã¹ã¯ããã®ç»åãŸãã¯ã¹ã¯ãªããïŒã®èªã¿åãã§ãããã«é¢ä¿ãªããã©ã®ãªããžã§ã¯ãã«å¯ŸããŠãå®è¡ã§ããŸãã ãŸããã·ã¹ãã ã«ã¯å€ãã®ããžãã¹ããžãã¯ã®ãªããžã§ã¯ãããããããŸããŸãªã¿ã€ãã§ããå¯èœæ§ããããããåçŽãªWebã¢ããªã±ãŒã·ã§ã³ã§ãã£ãŠãã1ã€ã®ãã¬ãŒã ã¯ãŒã¯å ã§èå¥åã«ããåŒã³åºããå€æ°çºçããå¯èœæ§ããããŸãã
ããŒã¿ãWebã¢ããªã±ãŒã·ã§ã³ã«åã蟌ãæ¹æ³ã§ãç§ãã¡ã¯æ±ºå®ããŸããããå éšã§äœãèµ·ããã®ã§ããããïŒ
ã¢ããªã±ãŒã·ã§ã³å ã®ãªã¯ãšã¹ãããã®ãã©ã¡ãŒã¿ãŒã¯ã©ããªããŸãã
æåã®èšäºã§ã¯ãååãšããŠããã¹ãŠã®ããŒã¿ãç¹å¥ãªããŒã¿ããŒã¹ã«ããŒãã«ã®åœ¢ã§æ ŒçŽããããã®ã¢ã¯ã»ã¹ã¯ããã¹ãã¯ãšãªã®åœ¢åŒã§æ§ç¯ãããã»ãšãã©ã®å Žåç¹å¥ãªSQLã¯ãšãªèšèªïŒæ§é åã¯ãšãªèšèª-æ§é åèšèªã¯ãšãªïŒã
éåžžãWebã¢ããªã±ãŒã·ã§ã³ã¯ãã¢ããªã±ãŒã·ã§ã³éçºè ãäœæããã³ãŒããšãŠãŒã¶ãŒããæž¡ããããã©ã¡ãŒã¿ãŒãçµã¿åãããSQLã¯ãšãªãäœæããŸãã äŸãèããŠã¿ãŸãããïŒ
SELECT title, text FROM news WHERE id=$id
ãã®äŸã§ã¯ã $ idã¯ãŠãŒã¶ãŒããæž¡ããããã©ã¡ãŒã¿ãŒïŒãªã¯ãšã¹ãã®å¯å€éšåïŒã§ãããæ®ãã®ãªã¯ãšã¹ãã¯éçã§ãããã¢ããªã±ãŒã·ã§ã³éçºè ãäœæããŸããã éçSQLã¯ãšãªã«ãŠãŒã¶ãŒããŒã¿å€æ°ãååšãããšãã¯ãšãªå šäœãåçã«ãªããŸãã
泚å°ã®æ¬è³ªã¯äœã§ããïŒ
SQLã®å Žåãæ³šå ¥ã®å šäœçãªãã€ã³ãã¯ãããŒã¿ããŒã¹ãžã®SQLã¯ãšãªãæªãŸããéåžžã®ã¯ãšãªãè£ ã£ãŠãµãŒããŒã«ãã¹ãªãããããããã«HTTPãªã¯ãšã¹ãã®ãã©ã¡ãŒã¿ãå€æŽããããšã§ãã ããã«ãããæ»æè ã¯ããŒã¿ãžã®äžæ£ã¢ã¯ã»ã¹ãååŸã§ããŸãã
ããŒã¿ããŒã¹ã«ãŠãŒã¶ãŒãã©ã³ã¶ã¯ã·ã§ã³ããŒã¿ãå«ãããã©ã³ã¶ã¯ã·ã§ã³ãããŒãã«ããããšããŸãã 次ã®ãã£ãŒã«ããå«ãŸããŸãã
- ãUser_idã-äžæã®ãŠãŒã¶ãŒèå¥å
- ãæ¥ä»ã-æ¥ä»
- ãéé¡ã-éé¡
- ã説æã-ç®ç
ãã©ã³ã¶ã¯ã·ã§ã³è¡š
user_id | æ¥ä» | é¡ | 説æ |
10 | 2015-05-26 | 1000 | ... |
11 | 2015-05-26 | 1500 | ... |
12 | 2015-05-26 | 1300 | ... |
n | 2015-05-26 | x | ... |
äžè¬çã«ãç¹æš©ãŠãŒã¶ãŒã§ã¯ãªãå ŽåãããŒã¿ããŒã¹ãåç §ããŠãã©ã³ã¶ã¯ã·ã§ã³ã«é¢ããæ å ±ãååŸã§ããŸãã ãã©ã³ã¶ã¯ã·ã§ã³user_id = 10ã®å Žå
2015幎5æ26æ¥ã®ååŒã«é¢ããããŒã¿ãåãåããã ãŠãŒã¶ãŒã®ã¢ã«ãŠã³ãã§ã¯ã次ã®ã¢ãã¬ã¹ã®ããŒãžã䜿çšã§ããŸãã
http://mybank.simplethreats.ru/transactions.jsp?date=2015-05-26
åŒã³åºããããšãæ¥ä»ã2015-05-26ããURLã®GETãã©ã¡ãŒã¿ãŒããååŸãããuser_idå€ãã¢ããªã±ãŒã·ã§ã³ã»ãã·ã§ã³ããååŸãããŸãã ãã®ããŒã¿ã«åºã¥ããŠããŠãŒã¶ãŒãã©ã³ã¶ã¯ã·ã§ã³ã«é¢ããæ å ±ãååŸããããã«ãã¢ããªã±ãŒã·ã§ã³ã¯SQLã¯ãšãªãçæããŸãã
SELECT * FROM transactions WHERE date = "2015-05-26" AND user_id = 10
ããè¯ãç解ã®ããã«SQLæ§æã«ç²ŸéããŠããªã人ã®ããã«ããã®ã¯ãšãªã解æããŸãããã
ãªã¯ãšã¹ãã®å 容
ã¯ãšãªã¯ãããŒãã«ããããŒã¿ãéžæããããã«äœ¿çšãããSELECTã¹ããŒãã¡ã³ãïŒè±èªããã®æåéã-â SELECT âïŒã§æ§æãããŸãã ãŸããUPDATEãINSERTãDELETEãšããæŒç®åããããååããæšæž¬ã§ããããã«ãããããè¡ã®æŽæ°ãæ¿å ¥ãåé€ã®æäœãå®è¡ããŸãã
èšå·ã*ãã¯ãããŒãã«ã®ãã¹ãŠã®åãéžæããããšãæå³ããŸãã 以äžã¯ãéžæãè¡ãããããŒãã«ã®ååãæã€ããŒã¯ãŒãFROMïŒæåéã-â FROM âïŒã§ãã
次ã¯WHEREããŒã¯ãŒãïŒæåéãè±èªã®ã WHERE ãããïŒã§ããã®åŸã«ããŒãã«ããéžæããããã®æ¡ä»¶ãçŽæ¥æ±ºå®ããéšåãç¶ããŸãã
ãã®åŸãããŒã¯ãŒãANDãŸãã¯ORã§åºåããããfield_name = valueããšãã圢åŒã®æ¡ä»¶ããããããããã AND ããšã OR ããæå³ããŸãã
ãããã£ãŠãã¯ãšãªãSQLãããã·ã¢èªã«ç¿»èš³ãããšã次ã®ããã«ãªããŸãã
ãã©ã³ã¶ã¯ã·ã§ã³ããŒãã«ãããã¹ãŠã®ãã£ãŒã«ããéžæããŸãWHERE field date = "2015-05-26" AND field user_id = 10ãŠãŒã¶ãŒããã®ããŒã¿ã®æ€èšŒãäžååãªå Žåãæ»æè ã¯ããŒã¿ããŒã¹èŠæ±ã®äžéšãå«ãã¢ããªã±ãŒã·ã§ã³ã®Webã€ã³ã¿ãŒãã§ã€ã¹ã®åœ¢åŒã«ç¹å¥ãªã³ãŒããæ¿å ¥ã§ããŸãã ãã®å±éºãªè匱æ§ã«ãããæ»æè ã¯èªååãã§ã¯ãªãæ å ±ãèªã¿åããå€æŽãåé€ã§ããŸãã
éå¶
ã©ã®ããã«æ©èœããŸããïŒ èæ ®ãããäŸã§ã¯ãæ¥ä»å€ã2015-05-26ãã¯ã¹ã¯ãªããURLããã®SQLã¯ãšãªã«è©²åœãããã®äŸã®ç®çã®ããã«ãã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠãã£ã«ã¿ãªã³ã°ãããŸããã
æ¥ä»2015-05-26ãšãšãã«æ¥ä»ãã©ã¡ãŒã¿ãŒã«ããã«ããã€ãã®æåãæž¡ãå ŽåïŒ
2015-05-26" AND user_id=11 --
æ£ãããã®ã®ä»£ããã«ïŒ
SELECT * FROM transactions WHERE date ="2015-05-26" AND user_id = 10
æå®ãããã¯ãšãªã¯ã次ã®SQLãçæããŸãã
SELECT * FROM transactions WHERE date = "2015-05-26" AND user_id = 11 -- " AND user_id = 10
SQLæ§æã®2ã€ã®ãã€ãã¹ã-ãã¯ã³ã¡ã³ãã®å§ãŸãã瀺ããŸãããããã£ãŠãã-ãã®åŸã®ãã¹ãŠã®æåã¯ã€ã³ã¿ãŒããªã¿ãŒã«ãã£ãŠåãå ¥ããããããŠãŒã¶ãŒIDãæ€èšŒããããªã¯ãšã¹ãã®äžéšã¯ããŒã¿ããŒã¹ãµãŒããŒã«ãã£ãŠåæãããŸãã
å®éã«ãªã¯ãšã¹ããå®è¡ãããŸãïŒ
SELECT * FROM transactions WHERE date = "2015-05-26" AND user_id = 11
ãã®çµæãå¥ã®ãŠãŒã¶ãŒã®ãã©ã³ã¶ã¯ã·ã§ã³ã«é¢ããæ å ±ãåãåããŸãã ãããŠãIDãä»ããŠãœãŒã-ä»ã®ãŠãŒã¶ãŒã
SQLã€ã³ãžã§ã¯ã·ã§ã³æ»æã®ãã¯ããã¯ã¯äœã§ãã
OWASPã³ãã¥ããã£ã§ã¯ ãSQLã€ã³ãžã§ã¯ã·ã§ã³æ»æã®5ã€ã®åºæ¬çãªæ¹æ³ïŒææ³ïŒ ã«ã€ããŠèª¬æããŠããŸãã
- Union æŒç®å ïŒ2ã€ã®ã¯ãšãªã1ã€ã®çµæãŸãã¯çµæã»ããã«çµåã§ããSELECTã¯ãšãªã«è匱æ§ãããå Žåããã®ã¢ãããŒãã䜿çšã§ããŸãã
- è«ççæ¹æ³ ïŒè«çæ¡ä»¶ããŸãã¯ç¹å®ã®ä»®å®ã®çåœã確å®ã«å€æã§ããæ¡ä»¶ã䜿çšããŸãã
- ãšã©ãŒã«åºã¥ã ïŒãã®æ¹æ³ã§ã¯ãWebã¢ããªã±ãŒã·ã§ã³ã«ãšã©ãŒã«é¢ããæ å ±ã匷å¶çã«çºè¡ãããããã«ãããŸããŸãªäžæ£ãªãªã¯ãšã¹ããæå³çã«è»¢éããŸããããã«åºã¥ããŠãæ»æè ã¯æ³šå ¥ãããæ£ãããªã¯ãšã¹ããäœæããã³éä¿¡ã§ããŸãã
- 代æ¿ããŒã¿äŒéãã£ãã«ã䜿çšããæ¹æ³ïŒãã®æ¹æ³ã¯ãæœåºãããããŒã¿ã®ä»£æ¿äŒéãã£ãã«ã®äœ¿çšã䌎ããŸãïŒäŸãã°ãWebãµãŒããŒãžã®çºä¿¡HTTPæ¥ç¶ãä»ããŠïŒ
- é 延æé ïŒãã®ã¡ãœããã¯ãã¹ãªãŒããªã©ã®ããŒã¿ããŒã¹ã³ãã³ãã䜿çšããŠãæ¡ä»¶ä»ãèŠæ±ã«ããé 延ã決å®ããŸãã ãã®ã¡ãœããã¯ãWebã¢ããªã±ãŒã·ã§ã³ããå¿çãååŸããæ¹æ³ããªãå Žåã«æå¹ã§ãïŒçµæããšã©ãŒïŒ
ããã«ããªã¹ããããææ³ã®2ã€ä»¥äžã®çµã¿åãããå«ãçµã¿åããã¢ãããŒãã䜿çšããããšãã§ããŸãã
3ã€ã®ã¿ã€ãã®æ»æã¯ãããŒã¿æœåºã®æ¹æ³ã«ãã£ãŠåºå¥ãããŸãã
- é¢é£ïŒæ¿å ¥ãããSQLã¯ãšãªã®çµæãšããŠã®ããŒã¿ã¯ãæ¿å ¥ãããã¯ãšãªãéä¿¡ãããã®ãšåãæ¹æ³ã§ååŸãããŸãã ããã¯æãåçŽãªã¿ã€ãã®æ»æã§ããããã®çµæãå€æŽãããèŠæ±ã«ãã£ãŠèŠæ±ãããããŒã¿ãWebã¢ããªã±ãŒã·ã§ã³ããŒãžã«çŽæ¥è¡šç€ºãããŸãã
- æªæ¥ç¶ ïŒæ¿å ¥ãããSQLã¯ãšãªããã®ããŒã¿ã¯ãå€æŽãããã¯ãšãªãéä¿¡ãããæ¹æ³ãšã¯ç°ãªãæ¹æ³ã§ååŸãããŸãã ïŒããšãã°ãããŒã¿ã¯é»åã¡ãŒã«ã¡ãã»ãŒãžã§æ»æè ã«éä¿¡ãããŸãïŒ
- æŒductiveçãŸãã¯ãã©ã€ã³ã ïŒSQLã€ã³ãžã§ã¯ã·ã§ã³ã®çµæãå®éã®ããŒã¿æœåºã¯è¡ãããŸããããæ»æè ã¯äžé£ã®ç¹å®ã®ã€ã³ãžã§ã¯ãSQLã¯ãšãªãéä¿¡ããçµæãšããŠWebãµãŒããŒã®åäœã芳å¯ããããšã«ããæ å ±ãååŸã§ããŸãã
èªåãå®ãæ¹æ³ã¯ïŒ
æšå¥šäºé ã¯éåžžã«ç°¡åã§ã-åä¿¡ããŒã¿ããã£ã«ã¿ãªã³ã°ããŸãã åæã«ããã£ã«ã¿ãªã³ã°ããåã«æããã«åœ¢åŒã«å¯Ÿå¿ããªãããŒã¿ãæã¡èŸŒãŸãªãæ¹ãè¯ãã§ãã èšãæãããšãå ¥åããŒã¿ããã©ãŒãããã«æºæ ããŠãããã©ããã確èªãããŠãŒã¶ãŒã«ãšã©ãŒãäžããå¿ èŠããããŸãã
ããšãã°ã衚瀺ãããã¥ãŒã¹IDãååŸããå¿ èŠããããŸãã ç§ãã¡ã®ã·ã¹ãã ã§ã¯ãããã¯åžžã«ãŒããã倧ããæŽæ°ã§ãããç§ãã¡ã¯ããã«ã€ããŠç¥ã£ãŠããŸãã æ°å€ãéä¿¡ãããªãå ŽåããŸãã¯ãã®æ°å€ããŒã以äžã®å Žåããšã©ãŒãã¹ããŒããŠã¹ã¯ãªãããåæ¢ããå¿ èŠããããŸãã
å€æ°ã®ç°ãªããšã³ããªãã€ã³ããæã€å€§èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ãæ¢ã«ããå Žåããã®æšå¥šäºé ã®å®è£ ãé²ããæ¹æ³ã¯ïŒ
ããŒã¿ããŒã¹ã€ã³ãžã§ã¯ã·ã§ã³ä¿è·ãå®è£ ããããã®äœç³»çãªã¢ãããŒããæäŸããŸãã ãã®ã¿ã€ãã®æ»æã«ããæœåšçãªè åšãæå°éã«æããã«ã¯ã次ã®æé ãé çªã«å®è¡ããå¿ èŠããããŸãã
- å€éšããWebã¢ããªã±ãŒã·ã§ã³ããããŒã¿ãåä¿¡ãããã¹ãŠã®ãã€ã³ããå®çŸ©ãããã¹ãŠã®ãšã³ããªãã€ã³ãïŒURLïŒãæž¡ããããã©ã¡ãŒã¿ãŒã®ååããããã³ã«ïŒHTTP / HTTPSïŒããã³ãããã®éä¿¡æ¹æ³ïŒGETãPOSTãPUTãŸãã¯DELETEïŒãæžãåºããŸãã
- 質åã«çããŠãåãã©ã¡ãŒã¿ãŒã®ããŒã¿åã決å®ããŸã-ã©ã®ãããªçš®é¡ã®å€ãååŸããå¿
èŠããããŸããïŒ
- åé å®ã®ããã«åãã©ã¡ãŒã¿ã®ãã§ãã¯ãå®è£
ããŸãã
- ããã¯ã¹ã©ãã·ã¥æåã\ãã䜿çšããŠãåŒçšç¬Šããã³ãã®ä»ã®ç¹æ®æåã®ãšã¹ã±ãŒããå®è£ ããŸãã ããã«ããªã¯ãšã¹ãå ã®ãã©ã¡ãŒã¿ãäžéåŒçšç¬Šã§å²ãŸããŠããå Žåã¯ãäžéåŒçšç¬Šããšã¹ã±ãŒãããã\ 'ãã§çœ®ãæããå¿ èŠããããŸããåæ§ã«äºéåŒçšç¬Šã§çœ®ãæããŸãã ãã®å ŽåãäºéåŒçšç¬Šå ã®åäžåŒçšç¬Šããšã¹ã±ãŒãããå¿ èŠã¯ãããŸãããéãåæ§ã§ãã çè«çã«ã¯ãå®éã«ã¯ãã»ãšãã©ãã¹ãŠã®äžè¬çãªãã¬ãŒã ã¯ãŒã¯ãšã¹ã¯ãªããèšèªã«ã¯ãphpã®mysqli_real_escape_stringãªã©ã®ç¹æ®æåããšã¹ã±ãŒãããããã®çµã¿èŸŒã¿é¢æ°ããããŸãã
äžè¬çã«ããã¹ãŠã®ããŒã¿ããŒã¹ã¯ãšãªã¯ãééããéã«ç¹å¥ãªãã¬ãŒãã³ã°ïŒãã£ã«ã¿ãªã³ã°ãšã·ãŒã«ãïŒãåããåäžãã€ã³ãïŒãã¬ãŒã ã¯ãŒã¯ãªã©ïŒãééããããšãæšå¥šã§ããŸãã
ãŸããSQLã€ã³ãžã§ã¯ã·ã§ã³æ»æãæåãããã«ã¯ãæ»æè ãæ§æçã«æ£ããSQLã¯ãšãªãéä¿¡ããå¿ èŠãããããšãèŠããŠããå¿ èŠããããŸãã ãã ãã誀ã£ãŠæ¿å ¥ããããªã¯ãšã¹ãã®çµæãšããŠWebã¢ããªã±ãŒã·ã§ã³ããšã©ãŒæ å ±ãè¿ãå Žåãæ»æè ã¯å ã®ãªã¯ãšã¹ãã®ããžãã¯ãå埩ããæ£ããæ¿å ¥ããæ¹æ³ãç解ã§ããããã«ãªããŸãã
ãããã£ãŠãã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠã©ã®ãšã©ãŒæ å ±ãæäŸããããã泚ææ·±ãç£èŠããå¿ èŠããããŸãã ããã§ããWebã¢ããªã±ãŒã·ã§ã³ããšã©ãŒã«é¢ããæ å ±ãé ããŠããå Žåãéçºè ã¯ãããã«ããŠããæåã®ãªã¯ãšã¹ãã®ããžãã¯ã埩å ã§ããå¿ èŠããããŸãïŒæãåçŽãªå Žåããšã©ãŒã®ãã°ãä¿æããŸãããç»é¢ã«ã¯è¡šç€ºããŸããïŒã
ä»ã«ã©ããªæ³šå°ããããŸããïŒ
ããŒã¿ããŒã¹ã€ã³ãžã§ã¯ã·ã§ã³ã«å ããŠãå€éšããçããŒã¿ãåä¿¡ããä»ã®ç°å¢ã¯ãã€ã³ãžã§ã¯ã·ã§ã³æ»æã®åœ±é¿ãåããå¯èœæ§ããããŸãã å¥ã®äžè¬çãªã±ãŒã¹ã¯ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ã·ã§ã«ã®ã€ã³ãžã§ã¯ã·ã§ã³ããããããOSã€ã³ãžã§ã¯ã·ã§ã³ãã§ãã
ãã³ãã³ãã€ã³ãžã§ã¯ã·ã§ã³ãOWASPã®èª¬æãããã®äŸãæ€èšããŠãã ããã
åçãããŠã³ããŒããããã®åŸåé€ããæ©èœããŠãŒã¶ãŒã«æäŸããç¹å®ã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ããããŸãã PHPèšèªã§èšè¿°ãããç¹å®ã®ã¹ã¯ãªããããããåçã®åé€ãæ åœããŸãã
<?php $file=$_GET['filename']; system("rm /var/www/user_photos/$file"); ?>
ãã®å žåçãªåŒã³åºãã¯æ¬¡ã®ããã«ãªããŸãã
http://mysocnet.simplethreats.ru/user_file_delete.php?filename=1246.jpg
ãããŠãã³ãã³ãã®å®è¡ã䌎ããŸãïŒ
rm /var/www/user_photos/1246.jpg
ãã®ãªã¯ãšã¹ããæž¡ãããšã§ãã¢ããªã±ãŒã·ã§ã³ã§ãã£ã¬ã¯ããªå šäœãã¯ãªã¢ããã®ã¯éåžžã«ç°¡åã§ãã
user_file_delete.php?filename=../ -rf
ïŒå®éãuser_file_delete.phpïŒfilename = ..ïŒ 2F + -rfã®ãããªURLã«è»¢éãããšãã¹ããŒã¹ãšç¹å®ã®æåããšã³ã³ãŒããããŸãããããããããããããã«ãã¹ããŒã¹ããã®ä»ã®æåãã©ããããã«èšè¿°ããŸãïŒ
å®è¡ã®åå ïŒ
rm /var/www/user_photos/.. ârf
ã«çãã
rm /var/www/ -rf
ã€ãŸãã確èªïŒ-fãã©ã¡ãŒã¿ãŒïŒããã³ååž°çïŒ-rãã©ã¡ãŒã¿ãŒïŒãªãã§ãã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã«ãä¿åãããŠããwwwãã£ã¬ã¯ããªã®å å®¹å šäœãåé€ããŸãïŒrfã³ãã³ãïŒã ãã¹ãŠã®ãµããã£ã¬ã¯ããªãšãã®ãã¡ã€ã«ã éåœ-ããªãã¯æµãæã¿ãŸããã
ãããŠãããªãã¯ãã¡ã€ã«ã·ã¹ãã ãåé€ããŠããã©ãŒã ã®ãªã¯ãšã¹ããæž¡ãããšã¯ã§ããŸããïŒ
user_file_delete.php?filename=12346.jpg && adduser ghost && echo ghostpass | passwd ghost âstdin
æ»æè ã¯æ¬¡ã®ã³ãã³ããå®è¡ããŸãã
rm /var/www/user_photos/12346.jpg && adduser ghost && echo ghostpass | passwd ghost âstdin
ãããŠããµãŒããŒã«ã¢ã¯ã»ã¹ããããã®ã¢ã«ãŠã³ããèªåã§äœæããŸãã
99ïŒ ã®ã·ã¹ãã ã®WebãµãŒããŒã¯ä»ã®ã¢ã«ãŠã³ããäœæã§ããªãéç¹æš©ãŠãŒã¶ãŒããå®è¡ããããããå®éã«ã¯ãã®æ¹æ³ã§ãŠãŒã¶ãŒãäœæããããšã¯ã»ãšãã©äžå¯èœã§ãã
UNIXã·ã¹ãã ãšãã®ã·ã§ã«ã®2ã€ã®æ©èœã«ãããæå®ãããã³ãã³ããã§ãŒã³ã®å®è¡ãå¯èœã§ãã
æåã®æ©èœã¯ãã€ãã©ã€ã³ïŒãã€ãã©ã€ã³ããã€ãããã€ãïŒã§ãã ãã€ãã©ã€ã³ã®æ¬è³ªã¯ãæŒç®åã|ãã§åºåãããŠããå Žåãããã³ãã³ãã®åºåãå¥ã®ã³ãã³ãã®å ¥åã«è»¢éã§ããããšã§ãã
2çªç®ã®æ©èœã¯ãè«çæŒç®åã&&ããšã||ãã䜿çšããŠã³ãã³ãã®çµã¿åãããå®è¡ããæ©èœã§ãã åã®ã³ãã³ããæ£åžžã«å®è¡ãããäœããã®è«çãANDãã§ããå Žåã&&æŒç®åã¯æ¬¡ã®æå®ãããã³ãã³ããå®è¡ããŸã-ã³ãã³ã1ãšã³ãã³ã2ãå®è¡ããŸãã æŒç®åã||ãã¯è«çãORãã«é¡äŒŒããŠãããæåã®ã³ãã³ããå®è¡ãããŠããªãå Žåã«ã®ã¿2çªç®ã®ã³ãã³ããå®è¡ããŸãïŒã³ãã³ã1ãŸãã¯ORã³ãã³ã2ãå®è¡ïŒã
次ã¯ïŒ
ãã¡ãããæ³šå ¥ã®ã«ããŽãªã«èµ·å ãããã®ã®ããäžéšã®ã¿ãèæ ®ããŸããã 巚倧ãªã¬ã€ã€ãŒã¯ãããããDOMãŸãã¯HTMLã€ã³ãžã§ã¯ã·ã§ã³ã«ãã£ãŠå æãããŸããããã«ãããXSSãªã©ã®ã¿ã€ãã®æ»æãå®è¡ã§ããããã«ãªããŸãã
XSSã®åé¡ã¯åžžã«ååã«æ·±å»ã§ãããåçã³ã³ãã³ãã®æ代ã«ã¯ãJavaScriptãéåžžã«åŒ·åãªæ©èœãæäŸããããããã®çš®ã®æ»æã®å±éºæ§ãé«ãŸããŸãïŒææããã¢ããªã±ãŒã·ã§ã³ãããªãã®åçãæ®ã£ãŠãæ»æè ã«åçãéä¿¡ã§ããç¯å²ïŒã
6æã«ãªãªãŒã¹ããã次ã®èšäºã®1ã€ã¯ãXSSã®åé¡ãšããã®çš®ã®æ»æã«å¯Ÿããæªçšãšä¿è·ã®æ¹æ³ã«ã€ããŠèª¬æããŸãã
èŠæããŠãã ããïŒ
SimplePayãšèè
ã«ã€ããŠå°ã
Ivan PritulaãšDmitry Agapitovã¯ã人ã
ã®ç掻ãããå¿«é©ã§å¿«é©ã«ãããœãªã¥ãŒã·ã§ã³ãéçºããŠããŸãã ä»æ¥ã¯ãæ°ãããµãŒãã¹ã®1ã€ã§ããæ¯æãã¢ã°ãªã²ãŒã¿ãŒSimplePayã玹ä»ããŸãã ç§ãã¡ãè¡ãããšã¯ãã¹ãŠãäžè¬çã«äžå®å
šæ§ãç¹ã«ç¹å®ã®ãœãããŠã§ã¢ãœãªã¥ãŒã·ã§ã³ã®äžå®å
šæ§ã«èããããšãå°é£ãªããšã§ãã åœç€Ÿã®è£œåãçãŸããã®ã¯ãåè¶æ§ãè¿œæ±ããããšã§ãã
SimplePayã¯ãææ°ã®ãã€ãã¯æ¯æãã¢ã°ãªã²ãŒã¿ãŒã§ãã å瀟ã¯2014幎ã«èšç«ãããã¢ã¹ã¯ã¯ã§ç»é²ããããã·ã¢é£éŠã®æ³åŸã«åŸã£ãŠæŽ»åãè¡ã£ãŠããŸãã ç§ãã¡ã®äž»ãªã¿ã¹ã¯ã¯ã掻åã®åéãããžãã¹ã®èŠæš¡ãèšç·Žãåããæè¡è ã®æç¡ã«é¢ä¿ãªããäŒæ¥ã®ãŠã§ããµã€ãã§æ¯æãã®åãå ¥ããæŽçããç°¡åã§äŸ¿å©ãªæ©äŒãæäŸããããšã§ãã
次ã®ãµãŒãã¹ãæäŸããŠããŸãã
çããªãã¡ã¬ã³ã¹ïŒ
SimplePayã¯ãææ°ã®ãã€ãã¯æ¯æãã¢ã°ãªã²ãŒã¿ãŒã§ãã å瀟ã¯2014幎ã«èšç«ãããã¢ã¹ã¯ã¯ã§ç»é²ããããã·ã¢é£éŠã®æ³åŸã«åŸã£ãŠæŽ»åãè¡ã£ãŠããŸãã ç§ãã¡ã®äž»ãªã¿ã¹ã¯ã¯ã掻åã®åéãããžãã¹ã®èŠæš¡ãèšç·Žãåããæè¡è ã®æç¡ã«é¢ä¿ãªããäŒæ¥ã®ãŠã§ããµã€ãã§æ¯æãã®åãå ¥ããæŽçããç°¡åã§äŸ¿å©ãªæ©äŒãæäŸããããšã§ãã
次ã®ãµãŒãã¹ãæäŸããŠããŸãã
- ãµã€ãã§æ¯æããåãåãçµç¹
- ãã€ã€ãŒãžã®æãæ»ã
- ãã€ã€ãŒãžã®ç¡æè«æ±
- URLãšé»åã¡ãŒã«ã®äž¡æ¹ã§ã®æ¯æãéç¥
- å®æçãªæ¯æã
- ãŠã©ã¬ããã䜿çšãããã¹ãŠã®äžè¬çãªæ¯æãã·ã¹ãã ã§ã®ç䌌å®ææ¯æã
çããªãã¡ã¬ã³ã¹ïŒ
- éè¡ååŸè ïŒPromsvyazbank
- 第äžè ã«æå©ãªæ¯æãïŒRNKO RIB
- 管èœïŒRFã161-FZ
- éå± äœè ãšé£æºããïŒããã
- ãã€ãã£ãAPIïŒã¯ã
- äºææ§ã®ããAPIïŒã¯ã
- CMSã¢ãžã¥ãŒã«ïŒã¯ã
- ãµãŒãããŒãã£ã·ã¹ãã ã®çµã¿èŸŒã¿ã¢ãžã¥ãŒã«ïŒBG BillingãWP-shop
- äžéããŒãžãªãã§PSã«çŽæ¥ãªãã€ã¬ã¯ãïŒã¯ã
- Return APIïŒã¯ã