ããã«ã¡ã¯ãæè¡é¨ã®é è¤ï¼@mametterï¼ã§ãããã«ã¿ã¤ã Ruby ã³ããã¿ã¨ãã¦ãã¯ãã¯ãããã«ãããããå ¥ç¤¾ãã¾ããããããããé¡ããã¾ãã
æè¿ãRuby ã RubyGems ã®èå¼±æ§ãçºè¦ãã¦ããã®çµæã»ãã¥ãªãã£ãªãªã¼ã¹ã«ã¤ãªããã¨ãããã¨ãçµé¨ãã¾ãããã©ãããåæ©ã§ã©ã®ããã«èå¼±æ§ãçºè¦ããããã©ã®ããã«éå ±ãããããªã©ã«ã¤ãã¦ã¾ã¨ãã¦ã¿ã¾ããRuby ã®èå¼±æ§ãè¦ã¤ãããã©ã©ãããããã¨ãã人ã®åèã«ãªãã°å¹¸ãã§ãã
HackerOne ã«ã¤ãã¦
HackerOne ã¨ããèå¼±æ§æ å ±ã®éå ±ã¨å ¬éã®ããã®ãã©ãããã©ã¼ã ããåç¥ã§ããããã
OSS ã«ã¨ã£ã¦èå¼±æ§æ å ±ã®ç®¡çã¯é¢åãªãã®ã§ããèå¼±æ§ã®éå ±ãç§å¯è£ã«åãä»ããé¢ä¿è ã ãã§è°è«ããªããã°ãªãã¾ããããã®ãããé常ã®ãã°ãã©ãã«ã¨ã¯å¥ã®ã³ãã¥ãã±ã¼ã·ã§ã³ãã£ã³ãã«ãç¨æããå¿ è¦ãããã¾ãã
ãã㧠HackerOne ã使ãã¾ããHackerOne ã¯ç°¡åã«è¨ãã°ãèå¼±æ§æ å ±ã®ç®¡çã«ç¹åããéå ¬éã®ãã°ãã©ãã«ãµã¼ãã¹ã§ããç»é²ãããOSSããã¸ã§ã¯ãã«å¯¾ãã¦èª°ã§ãèå¼±æ§æ å ±ãéå ±ã§ãã¾ããã¾ããããã¸ã§ã¯ãã¡ã³ãéãå ±åè ã®éã§éå ¬éã®è°è«ãã§ãã¾ããåé¡ã解決ãããéã«ã¯è°è«ã®å 容ãå ¬éããã¾ãã
ããã«ãInternet Bug Bounty (IBB) program ãã¤ã³ã¿ã¼ããããç¶æããããã«ç¹ã«éè¦ãªã½ããã¦ã§ã¢ã¨æå®ãã¦ããä¸é¨ã®ããã¸ã§ã¯ãã«ã¤ãã¦ã¯ãéå ±ããããã°ãéçºè ã«ãã£ã¦èå¼±æ§ã¨èªå®ãããå ´åãIBB ããå ±åè ã«å ±å¥¨éãæ¯æããã¾ãã
ãã ãå ±å¥¨éãåºãã®ã¯è¯ãæªãã§ããè¯ãéå ±ããã¦ããã人ãå ±ãããã®ã¯å½ç¶è¯ããã¨ãªã®ã§ãããå ±å¥¨éç®å½ã¦ã®éãªææãããããæ¥ãã¨ããå¯ä½ç¨ãããã¾ããå®å ¨ã«è¦å½éããªä¾ãä¸ããã¨ããSVN ãå ¬éç¶æ ã ãï¼ãã¨ããããã°ãã©ãã«ã® issue ä¸è¦§ã丸è¦ãã ãï¼ãã¨ã 1 ããã¡ããæçãªéå ±ãæ¥ãã®ã§ãããéå ±ãåããå´ã¨ãã¦ã¯ãããã¡ãã£ã¨ãã¤ãºãæ¸ãã¨ãããªããã¨æã£ã¦ãã¾ãã
ããã§ã Ruby ã¦ã¼ã¶ã®æ¹ã ã« HackerOne ãç´¹ä»ãããã¨æãããã®ããã«ä¸åãç§èªèº«ãéå ±è ã¨ãã¦ã®ããã»ã¹ãçµé¨ãã¦ã¿ã¾ããã
ã¿ã¼ã²ããã®é¸å®
èªåãä¸çªæ £ãã¦ãã OSS ããã¸ã§ã¯ã㯠Ruby ãªã®ã§ãRuby ã®ã½ã¼ã¹ã³ã¼ãããèå¼±æ§ãæ¢ããã¨ã«ãã¾ãã 2 ãRuby ã«æ¨æºæ·»ä»ãããã©ã¤ãã©ãªã®ä¸ã§ããèå¼±æ§ã¨ããã° WEBrickããã¨ããç´è¦³ã«ãã¨ã¥ãããã®ã¸ããã¿ã¼ã²ããã«ãã¾ããã
æ¢ãèå¼±æ§ã®é¸å®
ãRuby ã®èå¼±æ§ãã«æ確ãªå®ç¾©ã¯ããã¾ããããã Rails ã¢ããªã«ä»»æã³ã¼ãå®è¡ï¼å¤é¨ããæ»æã³ã¼ããéãè¾¼ãã§å®è¡ãããããï¼ãããã°ãã©ããã«èå¼±æ§ããããã¨ã¯ç¢ºãã§ãããRuby ã®èå¼±æ§ãããããªãããRailsï¼ã¾ãã¯ãµã¼ããã¼ãã£ï¼ã®èå¼±æ§ãããããªãããã¯ãã¾ãã¦ã¼ã¶ã®æ¸ããããã°ã©ã ã®èå¼±æ§ããããã¾ããã極端ãªä¾ã§ã¯ãsystem("ls " + user_input)
ã¿ãããªããã°ã©ã ããã㨠OS ã³ãã³ãã¤ã³ã¸ã§ã¯ã·ã§ã³ãã§ãã¾ãããããã Ruby ã® system
ã®ããã ã¨è¨ããã¦ãå°ãã¾ããRuby æ¬ä½ãã¦ã¼ã¶ããã°ã©ã ãã®åãåãã¯ãããã¨æããããã¨ããã§ãã
ä»åã¯ããã§æããªããããè¨ãéããã«ããèå¼±æ§ãæ¢ããã¨ã«ãã¾ãããããã¯ããã®ããã¸ã§ã¯ãèªèº«ãéå»ã«èå¼±æ§ã¨èªãããã°ã«è¿ããã°ãè¦ã¤ãããã¨ã§ãã
WEBrick ã®éå»ã®èå¼±æ§ãæ¢ãããããWEBrick ã«ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹æ¿å ¥ã®èå¼±æ§ããè¦ã¤ããã¾ãããè¦ããã«ããã°ã«ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãç´ãè¾¼ã¾ãããã¨ãã§ãããèå¼±æ§ã®ããã§ããå人çã«ã¯ããã®ãããã§èå¼±æ§ãªãã ãã¨ããé©ããããã¾ãããä¸é¨ã®ã¿ã¼ããã«ã¨ãã¥ã¬ã¼ã¿ã¯ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã§å±ããæåãèµ·ããããã¨ãããããã§ãã詳ããã¯ãªã³ã¯å ãèªãã§ä¸ããã
èå¼±æ§ã®çºè¦
å®éã«èå¼±æ§ãæ¢ãã¾ããéå»ã®èå¼±æ§ã®ä¿®æ£ã³ããããæãããã« WEBrick ã®ãã°åºåã¾ãããèªè§£ããã¨ãWEBrick::AccessLog.escape
ã¨ããã¡ã½ããã§ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãé¤å»ï¼ãµãã¿ã¤ãºï¼ããWEBrick::BasicLog#error
ã #warn
ãªã©ã®ã¡ã½ããã§å®éã«ãã°ãæ¸ãåºãããããã¨ããããã¾ããããã§ãAccessLog.escape
ã WEBrick::HTTPStatus::Status#initialize
ã®ä¸ã§ããå¼ã°ãã¦ããªããã¨ã«æ°ã¥ãã¾ãããã¤ã¾ãããã®ä¾å¤çµç±ã§ãããµãã¿ã¤ãºããããªããããã¨ãããã¨ã§ãã
ããã§ã#error
ã #warn
ãç´æ¥å¼ã³åºãã¨ãããæ¢ããã¨ãããWEBrick::HTTPAuth::BasicAuth#initialize
ã«è¦ã¤ããã¾ãããä¸æ£ãªã¦ã¼ã¶ ID 㧠BASIC èªè¨¼ããã¨ããã®ã¦ã¼ã¶ ID ããµãã¿ã¤ãºãªãã§ãã°ã«æµãåºãããã§ãã
ï¼ãã£ããè¦ã¤ããããã«æ¸ãã¦ã¾ãããå®éã«ã¯ããããæ¢ããã試è¡é¯èª¤ãããããªããã ã£ãã®ã§ 2 æ©ãããã¯ããã£ãã¨æãã¾ãï¼
èå¼±æ§ã®ç¢ºèª
ãã®èå¼±æ§ãå®éã« exploit å¯è½ã§ãããã¨ã確ããã¾ããWEBrick ã® BASIC èªè¨¼ã®ã³ã¼ãã Web æ¤ç´¢ããªããæ¸ãã¾ãã
require "webrick"
require "webrick/httpauth"
srv = WEBrick::HTTPServer.new({ Port: 34567 })
db = WEBrick::HTTPAuth::Htpasswd.new("dot.htpasswd")
authenticator = WEBrick::HTTPAuth::BasicAuth.new(UserDB: db, Realm: "realm")
srv.mount_proc("/") do |req, res|
authenticator.authenticate(req, res)
res.body = "foobar"
end
srv.start
âãµã¼ããèµ·åããæ§å
ãã®ãµã¼ãã«å¯¾ãã¦ãã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãæ··å
¥ããä¸æ£ãªã¦ã¼ã¶ ID ã§ãã°ã¤ã³ã試ã¿ã¾ããããã§ã¯ã"\e]2;BOOM!\a"
ã¨ããã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã§å®é¨ãã¾ãããããã¯ã端æ«ã®ã¿ã¤ãã«ã BOOM!
ã¨ããæååã«å¤ããå½ä»¤ã§ãã
require "open-uri"
open("http://localhost:34567/login",
http_basic_authentication: [
"ESCAPE SEQUENCE HERE->\e]2;BOOM!\a<-SEE WINDOW TITLE",
"passwd"
]).read
âã¯ã©ã¤ã¢ã³ããèµ·åããæ§å
ãã®çµæãWEBrick ãµã¼ããåããã¦ãã端æ«ã®ã¿ã¤ãã«ããBOOM!
ã«å¤ãããã¨ã確èªã§ãã¾ããã
âæ»ææåããæ§åï¼ã¿ã¤ãã«ãã¼ã "BOOM!" ã«ãªã£ã¦ããã¨ããããã¤ã³ãï¼
èå¼±æ§ã®å ±å
ãã§ãã(?)èå¼±æ§ã確èªã§ããã®ã§ãHackerOne ã«æ稿ãã¾ããWeakness ã Severity ã¯è©²å½ããã¨æããã®ãé¸ã¶ã ãã§ãããããããããªãã£ãã空æ¬ã§ãããããã§ããéè¦ãªã®ã¯ Proof of Concept ã§ããã¨ãã£ã¦ããæ®éã®ãã°å ±åã¨åãã§ããã©ãããåé¡ã§ãããã¨ãåç¾æé ããã£ã¡ãæ¸ãã°ååã§ããããåé¡ã®é大ããæ¸ãã¨ããã«è¦ªåã§ããä»åã®èå¼±æ§ã¯éå»ã®èå¼±æ§ã®ä¿®æ£æ¼ããªã®ã§é大ãã«è°è«ã®ä½å°ã¯ãªãã¨èããã»ã¨ãã©åç¾æé ã ããç°¡åã«æ¸ãã¾ããã
ãã¨ã¯æ®éã®ãã°å ±åã¨åã対å¿ã§ãããã»ã©è´å½çãªåé¡ã§ãªãéãï¼ãããã¯è´å½çãªåé¡ã§ãã£ã¦ãï¼ãéçºè ã¯ãªããªãè¿äºããã¦ãããªããã®ã§ããããããæ¸ãã¦éã£ãããã¨ãã©ãå¬ä¿ãããããªãããæ°é·ã«å¾ ã¡ã¾ããä»åã¯ã4 æã«å ±åãã¦ãã»ãã¥ãªãã£ãªãªã¼ã¹ã¯ 9 æã§ããã
ã»ãã¥ãªãã£ãªãªã¼ã¹
æ®éã®å ±åè ãªãããã§çµããã§ãããä»åã¯ç§ã Ruby ã³ããã¿ã§ãããã¨ãããã¨ã§ãã»ãã¥ãªãã£ãªãªã¼ã¹ã«å°ãã ãåå ãã¾ãããã¨ãã£ã¦ãç§ããã£ãã®ã¯ããã©ã³ãããã¼ã¸ã£ãå ¬å¼ãµã¤ã管ç人ãã¡ï¼@unak ããã@nagachika ããã@hsbt ããï¼ã®æ示ã®ä¸ãç§ãæ¸ããããããã³ãããããã ãã§ãããã¨ã¯å½¼ããä¸çæ¸å½ tar ball ãä½ã£ã¦ãªãªã¼ã¹ããã®ãå¿æ´ãã¦ãã¾ããã
ã³ããããã¦ãããªãªã¼ã¹ã¢ãã¦ã³ã¹ãåºãã¾ã§ã®æéãæå°åããããããªã¢ã«ã¿ã¤ã ã®ã³ãã¥ãã±ã¼ã·ã§ã³ãåããªããé²ããå¿ è¦ãããã¾ããRuby ã®ãã©ã³ãããã¼ã¸ã£ãã¡ã¯ãã»ãã¥ãªãã£ãªãªã¼ã¹ã®ãã³ã«å½ãçããã¦é å¼µã£ã¦ãã¾ããæ¬ç¤¼ã
å ±å¥¨éã®ç²å¾
ç¡äºã»ãã¥ãªãã£ãªãªã¼ã¹ããªãããã¨ãããã¨ã§ãIBB ããå ±å¥¨éã¨ã㦠$500 ãããã ãã¾ããããã®ããã»ã¹ãç°¡åã«èª¬æãã¦ããã¾ãã
ã¾ããåãã¦å ±å¥¨éããããå ´åãç¨åä¸ã®æ¸é¡ W-8BEN ãä½æãã¦æåºãã¾ã 3 ããã¹ã¦ãªã³ã©ã¤ã³ã®æç¶ããªã®ã§é£ãããã¨ã¯ããã¾ããã§ããã
ããããæ¯æãã®ååæ¹æ³ãç»é²ãã¾ããPayPal ãBitcoin via Coinbase ãéè¡éæ¯æ¿ããµãã¼ãããã¦ãã¾ãããç§ã¯éè¡éæ¯æ¿ãé¸ãã ã®ã§ãå£åº§æ å ±ãå ¥åããã ãã§ããã4
RubyGems ã®èå¼±æ§
åããããªããã»ã¹ã§ãRubyGems ã«ãéå ±ããã¾ããã
詳細ã¯å²æãã¾ãããCVE-2015-3900 ã¨ããéå»ã®èå¼±æ§ãé©åã«ä¿®æ£ããã¦ããªãã¨ãããã®ã§ããããã ããã¡ãã¯ãã§ã«ä»ã®äººãéå ±æ¸ã¿ã ã£ãã®ã§ãDuplicate ã§ã¯ãã¼ãºããã¾ããã
ãã ãã³ã¼ããèªãã§ãããã¡ã«æ¬¡ã® 3 ã¤ã®åé¡ãæ°è¦çºè¦ãã¾ããããã¡ãã®æ¹ã®éå ±ã¯èªããããããã§ãã
- summary ã«ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãæ··ãããã
- summary ã®æååé·ã«å¶éããªã
- æ¢åãã¡ã¤ã«ãä¸æ¸ãã§ãããã¨ããã
ãããã®éå ±ã«å¯¾ããä¿®æ£ã¯ãRubyGems 2.6.13 ã¨ãã¦ãªãªã¼ã¹ããã¦ãã¾ããç¹ã« 3 ã¤ãã®åé¡ã¯ãWEBrick ã®åé¡ããããå°ãé大ã ã¨æãã®ã§ããã¼ã¸ã§ã³ã¢ãããããã¨ããããããã¾ãããªããRuby 2.4.2 㯠RubyGems 2.6.13 ã®ä¿®æ£ãå«ãã§ããã®ã§ãRuby 2.4.2 ã«ããã®ã§ã大ä¸å¤«ã§ãã
ã¾ã¨ãã¨ææ
Ruby ã®èå¼±æ§ãæ¢ã㦠HackerOne ã«éå ±ããäºä¾ãç´¹ä»ãã¾ããã
ã»ãã¥ãªãã£å ±åãããã¨ãå¤ãã®å ´åãå ¬å¼ãµã¤ãã§ã¯ã¬ã¸ããã«è¼ãã¦ããããã®ã§ãæ¿èªæ¬²æ±ãæºãããã¾ãããHackerOne ãªãã¡ãã£ã¨ããå ±å¥¨éã¾ã§ãããã¾ã 5 ã
æåã«è§¦ããã¨ãããä»ã®ã¨ãã HackerOne çµç±ã§ Ruby ã«ããéå ±ã¯ãéãªéå ±ãå¤ã㦠Ruby éçºè çã«ã¯ãã¤ãºãå¤ãã¨æãããã¦ãã¾ãããã®è¨äºãè¦ã人ããï¼Ruby ã«éããï¼ææ義ãªéå ±ãå¢ããã¦ãããã¨ãããªã¨æãã¾ãã
æå¾ã«ãªãã¾ããããã¯ãã¯ãããã§ã¯èå¼±æ§ã®ãªã Rails ã¢ããªãä½ãã Web ã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ãåéãã¦ãã¾ãã詳ããã¯åéè¦é ãã¼ã¸ãã覧ãã ããã
-
Ruby ã¯ãªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ããªã®ã§ããã¡ããæå³çã«å ¬éãã¦ãã¾ãã↩
-
IBB ã® FAQ ã«ããã¨ãããã¸ã§ã¯ãã®éçºè èªèº«ã§ãã(1) ãã®ããã¸ã§ã¯ãã§åå ¥ãå¾ã¦ããªããã¨ã(2) åé¡ã®ã³ãããã«é¢ãã£ã人éã§ãªããã¨ãã®æ¡ä»¶ãæºããã°å ±å¥¨éããããã¾ããç§ã¯ãã«ã¿ã¤ã ã³ããã¿ã«ãªã£ãã®ã§ãããç¡è³æ ¼ã®ããã§ãããä»åã®éå ±ã¯å ¥ç¤¾åã«ããã¾ããã↩
-
ç±³å½éå± ä½è ãç±³å½ã®äººããæ¯æããåãåãã¨ãã«ãæºæ³å¾´åã®éé¡ãä½æ¸ãã¦ãããããã®æ¸é¡ã↩
-
æ£ç¢ºã«ã¯ãæµ·å¤ããã®ééãåãåãããã«ãéè¡ã«ãã¤ãã³ãã¼ã®ç»é²ãããæç¶ããããã¾ããã↩
-
ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã¤ã³ã¸ã§ã¯ã·ã§ã³ã§ã¯å¤§ããéé¡ã«ã¯ãªãã¾ããã§ãããããã£ã¨é大ãªèå¼±æ§ãªããããªãã«é«é¡ã«ãªãã¯ãã§ãããã¨ãã°æå㪠Shellshock ã 㨠$20,000 ãæ¯æãããããã§ãã↩