piyokangoããã詳ãããèªåãå°ã調ã¹ãã®ã§ã
ã©ããªèå¼±æ§ï¼
å¤é¨ããã®å ¥åã«ãããæå³ããã«ããã¡ã¤ã«ãèªã¿ããã ãããã¡ã¤ã«ã移åããããåé¤ããããç¹å®ã®URLã«ã¢ã¯ã»ã¹ããããä»»æã®ã³ã¼ããå®è¡å¯è½ãªèå¼±æ§ã
ã©ãããã¢ããªãæ»æãããï¼
ç»åãã¢ãããã¼ããã¦ImageMagickã使ã£ã¦å¤æããã¿ãããªãµã¼ãã¹ãçãããããªã
ã©ãããä»çµã¿ã§æ»æãã¦ããã®ã
ImageMagickã¯ããããªç¨®é¡ã®ãã¡ã¤ã«ãå¦çã§ãããããã®ããã«coderã¨delegateã¨ããæ©è½ããããcoderã¯ã©ã¤ãã©ãªã¨ãã¦å種ãã¡ã¤ã«ãå¤æããæ©è½ãdelegateã¯é©åãªcoderããªãã£ãæã«ãå¤é¨ã³ãã³ããç¨ãã¦å¤æããæ©è½ã§ããã
CVE-2016-3714(ã³ã¼ãå®è¡ã®èå¼±æ§)ã«ã¤ãã¦ã¯ãdelegateã®æ©è½ã§å¤é¨ã³ãã³ããå¼ã³åºãæã«systemé¢æ°ãå©ç¨ãã¦ããããshellã®ç¹æ®æåã®ã¨ã¹ã±ã¼ããå®æ½ãã¦ããªãã£ããã¨ã主ãªåå ã
ä¾ãã°ã
convert https://www.imagemagick.org/image/wizard.png wizard.png
ãå®è¡ããã¨ãimagemagickã®ãµã¤ãããwizard.pngããã¦ã³ãã¼ããã¦wizard.pngã¨ãããã¡ã¤ã«ã«ä¿åãã¦ããã
å
é¨çã«ã¯æ¬¡ã®ãããªå¦çãè¡ã£ã¦ããã
ImageMagickã¯convertã®å¤æå
(第ä¸å¼æ°)ãHTTPSã¨ãã種é¡ã®ãã¡ã¤ã«ã¨ã¿ãªããHTTPSã®coderã¯åå¨ããªãã®ã§ãdelegateãæ¢ããdelegateã¯delegates.xmlã«è¨è¿°ããã¦ãããCentOS6ã§ã¯ä»¥ä¸ã®ãã®ã該å½ãã
<delegate decode="https" command=""curl" -s -k -o "%o" "https:%M""/>
ImageMagickã¯commandã®é¨åã®ã³ãã³ããå®è¡ããã%Mã«ã¯å ¥åãã¡ã¤ã«åã渡ããããããã%Mãç½®æããéã«shellã®ç¹æ®æåã®ã¨ã¹ã±ã¼ããå®æ½ãã¦ããªãã®ã§ã
convert 'https://www.imagemagick.org/image/wizard.png"|ls "-la' wizard.png
ãå®è¡ããã¨
"curl" -s -k -o "wizard.png" "https://www.imagemagick.org/image/wizard.png"|ls "-la"
ãå®è¡ãããlsãå®è¡ããããã¨ã«ãªãã
ããã ãã ã¨ãæ®éã®ã¢ããªã ã¨å¤é¨ã®å ¥åããã®ã¾ã¾convertã®å¼æ°ã«ããªããã大ä¸å¤«ãããªããã¨æããããããã®å¦çãç»åãã¡ã¤ã«ã®ä¸ã«é ããã¨ãã§ããã
ImageMagickã«ã¯SVGã¨MVG(ImageMagickç¬èªã®ããã¹ããã¼ã¹ã®ç»åãã©ã¼ããã)ã®coderãããããããã®ãã©ã¼ãããã¯å¤é¨ã®URLããã¡ã¤ã«ãåç §ã§ãããä¾ãã°ä»¥ä¸ã®MVGãã¡ã¤ã«ã¯å¤é¨URLhttps://example.com/image.jpgãå«ãã
push graphic-context viewbox 0 0 640 480 fill 'url(https://example.com/image.jpg)' pop graphic-context
ãã®å¤é¨URLåç §ã«å¯¾ãã¦ãcoder/delegateãå®è¡ããããä»åã®å ´åã¯HTTPSãã©ã¼ãããã ã¨ã¿ãªãããHTTPSã®delegate commandãå®è¡ãããä»»æã®ããã»ã¹ãèµ·åã§ããã
ããã«ãImageMagickã¯ãã®ãã¡ã¤ã«ãã©ã®ãã©ã¼ãããã®ãã¡ã¤ã«ãã«ã¤ãã¦
- ãã¸ãã¯ãã¤ã
- format:filenameå½¢å¼ã®prefix
- æ¡å¼µå(filename.suffix)
ã®åªå é ä½ã§ãã§ãã¯ãããSVGãMVGã¯ãã¸ãã¯ãã¤ãããã§ãã¯ãããã®ã§ãæ¡å¼µåã§pngãªã©ãæå®ãã¦ããã¨ãã¦ããä¸èº«ãSVG/MVGãªãã°SVG/MVGã¨è§£éããã¦ãã¾ãã
ãã®ãããMVGãã¡ã¤ã«ãã¢ãããã¼ãããâconvertã§ãã¡ã¤ã«ãå¦çãããã¨ããã¨MVGã®coderãå®è¡ãããâURLãåç §ãã¦ããé¨åã§ã³ã¼ããå®è¡å¯è½ã¨ãããã¨ã«ãªãã
ãã®ä»ã®èå¼±æ§ã«ã¤ãã¦ã ããshellã³ãã³ãã®ã¨ã¹ã±ã¼ãã®åé¡ã¯ãªããã®ã®ãããããMVGå ã«å¤é¨ã®ãã¡ã¤ã«ãURLãåç §ãããã¨ã«ããããã¡ã¤ã«/URLã®èªã¿æ¸ããè¡ã£ã¦ãã¾ããã¨ãåå ã¨ãªã£ã¦ããã
ä¿®æ£çã¯ï¼
ææ°ç(7.0.1-1)ãã¤ã³ã¹ãã¼ã«ããã¨é²ããããã§ããã
å®éã«åããã¦ã¿ãã¨ä¸é¨ããé²ããªã(Ãã¯é²ãã¦ããªã)ã®ã§policy.xmlã§é²ãå¿ è¦ãããã
CVE | å 容 | é²ããï¼ |
---|---|---|
CVE-2016-3714 | delegateã«ããRCEèå¼±æ§ | â |
CVE-2016-3718 | SSRF(URLã«å¯¾ããGET) | à |
CVE-2016-3715 | ephemeralãããã³ã«ã«ãããã¡ã¤ã«ã®åé¤ | à |
CVE-2016-3716 | mslãããã³ã«ã«ãããã¡ã¤ã«ã®ç§»å | â*1 |
CVE-2016-3717 | labelãããã³ã«ã«ãããã¡ã¤ã«ã®èªã¿è¾¼ã¿ | à |
åé¿çã¯ï¼
èå¼±æ§å ¬å¼ãµã¤ãã«ããã¨ä»¥ä¸ã®ã©ã¡ããã§é²ããã
- ãã¸ãã¯ãã¤ãããã§ãã¯ãã
- policy.xmlã«ä»¥ä¸ãæå®
<policymap> <policy domain="coder" rights="none" pattern="EPHEMERAL" /> <policy domain="coder" rights="none" pattern="URL" /> <policy domain="coder" rights="none" pattern="HTTPS" /> <policy domain="coder" rights="none" pattern="MVG" /> <policy domain="coder" rights="none" pattern="MSL" /> <policy domain="coder" rights="none" pattern="TEXT" /> <policy domain="coder" rights="none" pattern="SHOW" /> <policy domain="coder" rights="none" pattern="WIN" /> <policy domain="coder" rights="none" pattern="PLT" /> </policymap>
coderã¨ãdelegateã®å¨ãã®å¦çã®æµãããããããã
ç§ãããããã£ã¦ããªããã以ä¸ã®ãããªæãããª
- ä»çµã¿ã®ã¨ããã«æ¸ããåªå
度ã§ãã©ã¼ãããã決ãã
- ãã¸ãã¯ãã¤ãã®ãã§ãã¯ã¯MagicCore/magic.cã®MagicMapã®å¤ãèªãã¨ãªãã¨ãªãããã
- magic.xmlã«ãã«ã¹ã¿ãã¤ãºãããã®ãæå®å¯è½ã ãã©ã
- ãã©ã¼ãããã«å¯¾å¿ããcoderãæ¢ããåå¨ããã°coderãå®è¡ãã
- ã©ã®ãã©ã¼ããããã©ã®coderã«è©²å½ãããã¯MagicCore/coder.cã®CoderMapãèªãã¨ãªãã¨ãªãããã
- coderãåå¨ããªããã°delegateãå®è¡ãã
RedHatã®åé¿çã¯å¾®å¦ï¼
ImageMagick Filtering Vulnerability - CVE-2016-3714ã®Resolveã®Mitigationã®ãã¨ã ããããããããã¯å¾®å¦ã ãRHEL 5ã§ã¯ä½¿ããªãããæ示çã«HTTPã¨FTPãç¦æ¢ãã¦ããçç±ãå¤ããªããç§ãã³ã¼ããçºããéãã§ã¯ãHTTPã¨FTPã¯URLãæä¾ãã¦ããããã ãããããã
policy.xmlが使えない古いImageMagickでImageTragickを回避する (2) - Qiita
ç§ãã³ã¼ããèªãã æãã ã¨coderã®policyãã§ãã¯ã¯coderåã«å¯¾ãã¦è¡ãã®ã§ã¯ãªãããã©ã¼ãããã«å¯¾ãã¦è¡ãã®ã§ãããªã«æªããªãæ°ãããããªãMagicCore/constitute.cã®ReadImageé¢æ°ã®é¨å
if (IsRightsAuthorized(domain,rights,read_info->magick) == MagickFalse) { errno=EPERM; (void) ThrowMagickException(exception,GetMagickModule(),PolicyError, "NotAuthorized","`%s'",read_info->filename); read_info=DestroyImageInfo(read_info); return((Image *) NULL); }
read_info->magickã«ã¯coderåã§ã¯ãªããã©ã¼ãããåãå ¥ãã
å®éã«MVGå ã«HTTPã®URLãæ¸ããå ´åã¯HTTPã®coderãnoneã«ããªãã¨é²ããªãã£ãã
ãã ãããããMVGãnoneã«ããæç¹ã§é²ãã話ã§ã¯ããã®ã ãã©ãã
ä¿®æ£å 容ã¯ã©ããªãã®ï¼
ãã¾ãã¡ç解ãããã¦ããªããä»åã®èå¼±æ§ã«é¢ãã¦7.0.1-1ã¾ã§ã«ä»¥ä¸ã®ä¿®æ£ãå ¥ã£ãã£ã½ãã
- Sanitize input filename for http / https delegates · ImageMagick/ImageMagick@06c41ab · GitHub
- delegates.xmlã®ä¸ã§%Fã§ãµãã¿ã¤ãºããå
¥åãã¡ã¤ã«åãåç
§ã§ããããã«ãªã£ã
- ãã ãããµãã¿ã¤ãºãä¸åå(ããã«ã¯ã©ã¼ããè¨è¿°å¯è½)
- delegates.xmlã®ä¸ã§%Fã§ãµãã¿ã¤ãºããå
¥åãã¡ã¤ã«åãåç
§ã§ããããã«ãªã£ã
- Indirect filename must be authorized by policy · ImageMagick/ImageMagick@58a2ce1 · GitHub
- @ã§ãã¡ã¤ã«åç §ããæã«ã¯policyãã§ãã¯ãè¡ãããã«ãã
- Second effort to sanitize input string · ImageMagick/ImageMagick@a347456 · GitHub
- 06c41abã§ä¸ååã ã£ããã®ãä¿®æ£
- ã¨ã¯ãã£ã¦ãã·ã§ã«ã®ç¹æ®æåãå ¨ã¦ãµãã¿ã¤ãºãã¦ããããã§ã¯ãªãã®ã§ã%F使ãæã注æãå¿ è¦ããª
- 06c41abã§ä¸ååã ã£ããã®ãä¿®æ£
ãã®å¾ã®ä¿®æ£
ä»åã®èå¼±æ§é¢ä¿ã§ã¾ã ããã¤ãä¿®æ£ãã¦ããã£ã½ãã
- Update to the latest autoconf / automake · ImageMagick/ImageMagick@e87116a · GitHub
- Use %F instead of %M for zero-configuration delegates · ImageMagick/ImageMagick@dcdd212 · GitHub
- delegates.xmlã«ä½ãè¨è¿°ããã¦ããªãå ´åãã½ã¼ã¹ã³ã¼ãå ã«è¨è¿°ãã¦ããããã©ã«ãã®XMLãèªãä»çµã¿ãããã®ã ããããã§%Fã使ã£ã¦ããªãã£ãã®ã§ä¿®æ£
- Remove support for internal ephemeral coder. · ImageMagick/ImageMagick@b831d90 · GitHub
- ephemeral coderèªä½ããªããªã£ãã
- Less secure coders require explicit reference (e.g. mvg:my-graph.mvg) · ImageMagick/ImageMagick@a58ba05 · GitHub
- ãã¸ãã¯ãã¤ãã§MVGãã©ãããå¤æããªããªã£ããã¤ã¾ããæ示çã«mvgãã¡ã¤ã«ã ã¨æ¡å¼µåãprefixã§æå®ããªãã¨mvgã¨ãã¦å¦çãããªããªãã
*1:ãªãé²ãã¦ããã®ãããããããªã