{"id":"GHSA-f3w6-w445-fwh9","kind":"vulnerability","aliases":["GHSA-f3w6-w445-fwh9"],"related":[],"title":"Possible arbitrary file write and read in Active Storage image analysis","description":"### Impact\nA Rails application that processes attachments with ImageMagick may allow an unauthenticated attacker to write arbitrary files on the server and, when attachments are stored with the Disk service, to read arbitrary files readable by the application process. Those files typically include `secret_key_base` and credentials for external systems, which may in turn allow escalation to remote code execution or lateral movement to those systems.\n\n### Details\nImageMagick selects a coder from the content of the file it is given, and some coders act on files named inside the image rather than on the image itself. Active Storage constrained none of ImageMagick's coders, and the ImageMagick analyzer runs when a file is attached, so an attacker who can upload a crafted file may be able to invoke one. Attaching the upload is sufficient; no variant, preview, or `analyze` call is required. One specific attack chain has been reported to us, but we do not assume it is the only one that exists.\n\nThe fixed versions ship an ImageMagick security policy and prepend its directory to `MAGICK_CONFIGURE_PATH` through `MiniMagick.cli_env`, so every ImageMagick process that MiniMagick spawns applies it. The policy denies the `MSL` scripting coder, the coders that read or delete files other than the image, fetch remote or local references, or display to a screen, every coder backed by Ghostscript together with the `gs` delegate, and `@filename` indirection. ImageMagick applies every `policy.xml` on its search path, so the shipped policy adds to the host's policy rather than replacing it. The policy applies to every ImageMagick command that MiniMagick runs, not only those of Active Storage. See the `activestorage` CHANGELOG and \"ImageMagick Security Policy\" in the Active Storage guide.\n\n### Affected applications\nAn application is affected if it meets all of these requirements:\n- Uses ImageMagick for Active Storage image processing. This is `config.active_storage.variant_processor = :mini_magick`, which is the default for applications on `load_defaults 6.1` or earlier.\n- Runs ImageMagick under a security policy that does not already deny the coders involved. The policies that Debian and Ubuntu package do not.\n- Allows file uploads from untrusted users.\n\n### Mitigation\n- Upgrade to a fixed version of `activestorage`.\n- An application whose variant processor is `:mini_magick` must use mini_magick `>= 5.1`, which applying the policy requires. With an older mini_magick, such an application raises an exception during boot.\n- An application that renders PostScript or PDF through ImageMagick must re-allow the `gs` delegate and the coders it uses in the host's `policy.xml`.\n- An application that replaces `MiniMagick.cli_env` after boot, clears the environment with `MiniMagick.cli_prefix`, or installs its own `MiniMagick::Shell` does not receive the shipped policy and must carry its rules in ImageMagick's system policy. GraphicsMagick does not read ImageMagick policies.\n- If attachments are stored with the Disk service, change `secret_key_base` and every secret readable by the application process, including the master key and everything `config/credentials.yml.enc` holds, storage and database credentials, and third-party tokens. Do not retain an exposed secret as a fallback.\n\n### Workarounds\nCopy the rules of the policy that the fixed versions ship, `activestorage/lib/active_storage/image_magick/policy.xml`, into ImageMagick's system policy, for example `/etc/ImageMagick-7/policy.xml`. At a minimum, deny the `MSL` coder, the Ghostscript coders, and the `gs` delegate:\n\n```xml\n<policy domain=\"coder\" rights=\"none\" pattern=\"MSL\"/>\n<policy domain=\"delegate\" rights=\"none\" pattern=\"gs\"/>\n<policy domain=\"coder\" rights=\"none\" pattern=\"{PS,PS2,PS3,EPS,EPS2,EPS3,EPI,EPSF,EPSI,EPT,EPT2,EPT3,PDF,AI,EPDF,PDFA,POCKETMOD,XPS,PCL}\"/>\n```\n\n### Releases\nThe fixed releases are available at the normal locations.\n\nPatches for those who cannot upgrade at once:\n- 8.1: https://github.com/rails/rails/commit/468aa9a93fc98f5476b6821770f4ccfcb7f7d328\n- 8.0: https://github.com/rails/rails/commit/ea8c40121ce53a3d0255cd4eb6d13bfe3bc01776\n\n### Versions affected\n- activestorage < 8.0.5.2\n- activestorage >= 8.1, < 8.1.4.1\n\n### Credit\nThis issue was responsibly reported by HackerOne researcher [ryotak](https://hackerone.com/ryotak).\n\n### References\n- ImageMagick [security policy](https://imagemagick.org/security-policy/)","summary":"Rails Active Storage passes uploaded images to ImageMagick without restricting its coders, so a crafted file can make ImageMagick write arbitrary files on the server. When attachments use the Disk service, the attacker can also read files the application process can read, such as secret_key_base and credentials.","severity":"critical","cvss":9.8,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"activestorage","fixed":["8.1.4.1"],"affected":">= 8.1, < 8.1.4.1","ecosystem":"rubygems"},{"name":"activestorage","fixed":["8.0.5.2"],"affected":"< 8.0.5.2","ecosystem":"rubygems"}],"ecosystems":["rubygems"],"tags":["activestorage","cwe-1188","imagemagick","mini_magick","package","rails","self-hosted"],"not_affected_if":["unpatched-versions-excluded","uploads-trusted-only","variant-processor-not-mini-magick"],"how_to_check":"- Check the `activestorage` version in `Gemfile.lock` against the affected ranges: `>= 8.1, < 8.1.4.1` and `< 8.0.5.2`.\n- Check whether `config.active_storage.variant_processor` is `:mini_magick` (the default on `load_defaults 6.1` or earlier).\n- Check whether the app accepts file uploads from untrusted users.","fix":"- `activestorage` 8.1.x: upgrade to `8.1.4.1`\n- `activestorage` 8.0.x: upgrade to `8.0.5.2`\n- Patches for teams that cannot upgrade at once are linked in the advisory (commits for 8.1 and 8.0).","status":"open","published_at":"2026-11-04T03:09:06+00:00","first_seen_at":"2026-11-09T22:53:28+00:00","triaged_at":"2026-11-09T22:54:06+00:00","updated_at":"2026-11-09T22:54:06+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-11-09T22:54:06Z","model":"claude-haiku-5-5","output":{"fix":"- `activestorage` 8.1.x: upgrade to `8.1.4.1`\n- `activestorage` 8.0.x: upgrade to `8.0.5.2`\n- Patches for teams that cannot upgrade at once are linked in the advisory (commits for 8.1 and 8.0).","reach":"internet","title":"Rails Active Storage: crafted image upload writes and reads server files","impact":"high","summary":"Rails Active Storage passes uploaded images to ImageMagick without restricting its coders, so a crafted file can make ImageMagick write arbitrary files on the server. When attachments use the Disk service, the attacker can also read files the application process can read, such as secret_key_base and credentials.","audience":"businesses","category":"package","nicknames":[],"who_cares":["rails","activestorage","imagemagick","mini_magick","self-hosted"],"confidence":0.85,"fix_status":"available","needs_auth":"no","worst_case":"Attacker writes server files and reads secret_key_base and credentials","analyst_note":"","how_to_check":"- Check the `activestorage` version in `Gemfile.lock` against the affected ranges: `>= 8.1, < 8.1.4.1` and `< 8.0.5.2`.\n- Check whether `config.active_storage.variant_processor` is `:mini_magick` (the default on `load_defaults 6.1` or earlier).\n- Check whether the app accepts file uploads from untrusted users.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["unpatched-versions-excluded","variant-processor-not-mini-magick","uploads-trusted-only"],"who_is_affected":"Rails applications that process attachments with ImageMagick through MiniMagick (the default variant processor on load_defaults 6.1 or earlier) and accept uploads from untrusted users, running under an ImageMagick policy that does not deny the risky coders (the Debian and Ubuntu default policies do not). Applications using the Disk service expose stored secrets to file reads. Apps on managed hosting that handle uploads should still confirm their ImageMagick policy; apps not using Active Storage image analysis are not in scope.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"yes","severity_if_unknown":"critical"},"cost_usd":0.001019,"input_tokens":6284,"output_tokens":781,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-1188':26B '/etc/imagemagick-7/policy.xml':608C '5.1':455C '6.1':403C '8.1':642C 'abl':210C 'act':168C 'activ':8A,36B,181C,353C,365C,384C 'activestorag':24B,357C,442C 'activestorage':22A,23A 'activestorage/lib/active_storage/image_magick/policy.xml':600C 'add':329C 'affect':368C,373C 'allow':94C,139C,429C,486C 'alreadi':415C 'also':69B 'analysi':11A 'analyz':192C,223C 'appli':274C,318C,341C,457C 'applic':73B,87C,121C,369C,371C,399C,444C,468C,475C,501C,560C 'arbitrari':2A,55B,100C,116C 'assum':240C 'attach':61B,90C,107C,198C,214C,543C 'attack':67B,97C,201C,229C 'avail':629C 'back':306C 'base':81B,129C,553C 'boot':473C,507C 'call':224C 'cannot':638C 'carri':528C 'chain':230C 'chang':550C 'changelog':358C 'clear':508C 'code':143C 'coder':46B,155C,167C,188C,282C,284C,305C,418C,492C,615C,618C 'command':345C 'config.active_storage.variant':390C 'config/credentials.yml.enc':568C 'configur':262C 'constrain':183C 'content':158C 'copi':589C 'craft':49B,206C 'credenti':83B,131C,573C 'cwe':25B 'databas':572C 'debian':423C 'default':397C,402C 'deleg':313C,489C,622C 'delet':288C 'deni':278C,416C,612C 'detail':151C 'directori':259C 'disk':64B,112C,548C 'display':300C 'earlier':405C 'env':266C,505C 'environ':510C 'escal':140C 'everi':268C,304C,319C,343C,555C 'everyth':567C 'exampl':607C 'except':471C 'execut':144C 'exist':247C 'expos':583C 'extern':133C 'f3w6':14A,19A 'fallback':587C 'fetch':294C 'file':3A,50B,56B,71B,101C,117C,124C,161C,170C,196C,207C,289C,430C 'filenam':315C 'fix':249C,439C,597C,626C 'fwh9':16A,21A 'ghostscript':308C,617C 'ghsa':13A,18A 'ghsa-f3w6-w445-fwh9':12A,17A 'gith':643C 'given':164C 'graphicsmagick':536C 'gs':312C,488C,621C 'guid':367C 'hold':569C 'host':34B,332C,497C 'imag':10A,40B,174C,179C,293C,386C 'imagemagick':27B,42B,53B,92C,152C,186C,191C,253C,269C,317C,344C,360C,382C,407C,482C,532C,540C,602C 'impact':84C 'includ':126C,562C 'indirect':316C 'insid':172C 'instal':515C 'invok':212C 'involv':419C 'key':80B,128C,552C,565C 'later':146C 'load':401C 'local':297C 'locat':633C 'magick':29B,261C,393C,450C,454C,465C 'make':52B 'master':564C 'may':93C,136C,208C 'meet':376C 'mini':28B,392C,449C,453C,464C 'minimagick':272C,347C,518C 'minimagick.cli':265C,504C,512C 'minimum':611C 'mitig':435C 'movement':147C 'msl':280C,614C 'must':451C,483C,527C 'name':171C 'none':184C 'normal':632C 'older':463C 'one':213C,227C,245C 'packag':30B,426C 'parti':577C 'pass':38B 'patch':634C 'path':263C,324C 'pdf':480C 'polici':255C,277C,328C,334C,340C,362C,411C,421C,459C,525C,535C,541C,594C,605C 'policy.xml':320C,499C 'possibl':1A 'postscript':478C 'prefix':513C 'prepend':257C 'preview':221C 'process':74B,89C,122C,270C,387C,561C 'processor':391C,447C 'rail':31B,35B,86C 'rais':469C 'rather':175C,335C 're':485C 're-allow':484C 'read':6A,70B,76B,115C,286C,539C 'readabl':118C,557C 'receiv':522C 'refer':298C 'releas':624C,627C 'remot':142C,295C 'render':477C 'replac':337C,503C 'report':233C 'requir':226C,380C,460C 'restrict':44B 'retain':581C 'rule':530C,591C 'run':193C,348C,406C 'screen':303C 'script':281C 'search':323C 'secret':79B,127C,551C,556C,584C 'secur':254C,361C,410C 'see':355C 'select':153C 'self':33B 'self-host':32B 'server':59B,104C 'servic':65B,113C,549C 'shell':519C 'ship':251C,327C,524C,599C 'spawn':273C 'specif':228C 'storag':9A,37B,182C,354C,366C,385C,570C 'store':109C,545C 'suffici':218C 'system':134C,150C,534C,604C 'third':576C 'third-parti':575C 'togeth':309C 'token':578C 'turn':138C 'typic':125C 'ubuntu':425C 'unauthent':96C 'untrust':433C 'upgrad':436C,639C 'upload':39B,204C,216C,431C 'us':235C 'use':62B,381C,452C,494C 'user':434C 'variant':220C,446C 'version':250C,440C,598C 'w445':15A,20A 'whose':445C 'without':43B 'workaround':588C 'write':4A,54B,99C 'xml':623C","nicknames":[],"mitigations":[],"who_affected":"Rails applications that process attachments with ImageMagick through MiniMagick (the default variant processor on load_defaults 6.1 or earlier) and accept uploads from untrusted users, running under an ImageMagick policy that does not deny the risky coders (the Debian and Ubuntu default policies do not). Applications using the Disk service expose stored secrets to file reads. Apps on managed hosting that handle uploads should still confirm their ImageMagick policy; apps not using Active Storage image analysis are not in scope.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"businesses","plain_action":null,"pkeys":["activestorage"],"ptokens":["activestorage"],"labels":["activestorage","critical","cwe1188","imagemagick","minimagick","package","rails","rubygems","selfhosted"],"campaign_type":null,"search_a":"'activ':8A 'activestorage':22A,23A 'analysi':11A 'arbitrari':2A 'f3w6':14A,19A 'file':3A 'fwh9':16A,21A 'ghsa':13A,18A 'ghsa-f3w6-w445-fwh9':12A,17A 'imag':10A 'possibl':1A 'read':6A 'storag':9A 'w445':15A,20A 'write':4A","search_b":"'-1188':26B 'activ':36B 'activestorag':24B 'also':69B 'applic':73B 'arbitrari':55B 'attach':61B 'attack':67B 'base':81B 'coder':46B 'craft':49B 'credenti':83B 'cwe':25B 'disk':64B 'file':50B,56B,71B 'host':34B 'imag':40B 'imagemagick':27B,42B,53B 'key':80B 'magick':29B 'make':52B 'mini':28B 'packag':30B 'pass':38B 'process':74B 'rail':31B,35B 'read':70B,76B 'restrict':44B 'secret':79B 'self':33B 'self-host':32B 'server':59B 'servic':65B 'storag':37B 'upload':39B 'use':62B 'without':43B 'write':54B","search_c":"'/etc/imagemagick-7/policy.xml':608C '5.1':455C '6.1':403C '8.1':642C 'abl':210C 'act':168C 'activ':181C,353C,365C,384C 'activestorag':357C,442C 'activestorage/lib/active_storage/image_magick/policy.xml':600C 'add':329C 'affect':368C,373C 'allow':94C,139C,429C,486C 'alreadi':415C 'analyz':192C,223C 'appli':274C,318C,341C,457C 'applic':87C,121C,369C,371C,399C,444C,468C,475C,501C,560C 'arbitrari':100C,116C 'assum':240C 'attach':90C,107C,198C,214C,543C 'attack':97C,201C,229C 'avail':629C 'back':306C 'base':129C,553C 'boot':473C,507C 'call':224C 'cannot':638C 'carri':528C 'chain':230C 'chang':550C 'changelog':358C 'clear':508C 'code':143C 'coder':155C,167C,188C,282C,284C,305C,418C,492C,615C,618C 'command':345C 'config.active_storage.variant':390C 'config/credentials.yml.enc':568C 'configur':262C 'constrain':183C 'content':158C 'copi':589C 'craft':206C 'credenti':131C,573C 'databas':572C 'debian':423C 'default':397C,402C 'deleg':313C,489C,622C 'delet':288C 'deni':278C,416C,612C 'detail':151C 'directori':259C 'disk':112C,548C 'display':300C 'earlier':405C 'env':266C,505C 'environ':510C 'escal':140C 'everi':268C,304C,319C,343C,555C 'everyth':567C 'exampl':607C 'except':471C 'execut':144C 'exist':247C 'expos':583C 'extern':133C 'fallback':587C 'fetch':294C 'file':101C,117C,124C,161C,170C,196C,207C,289C,430C 'filenam':315C 'fix':249C,439C,597C,626C 'ghostscript':308C,617C 'gith':643C 'given':164C 'graphicsmagick':536C 'gs':312C,488C,621C 'guid':367C 'hold':569C 'host':332C,497C 'imag':174C,179C,293C,386C 'imagemagick':92C,152C,186C,191C,253C,269C,317C,344C,360C,382C,407C,482C,532C,540C,602C 'impact':84C 'includ':126C,562C 'indirect':316C 'insid':172C 'instal':515C 'invok':212C 'involv':419C 'key':128C,552C,565C 'later':146C 'load':401C 'local':297C 'locat':633C 'magick':261C,393C,450C,454C,465C 'master':564C 'may':93C,136C,208C 'meet':376C 'mini':392C,449C,453C,464C 'minimagick':272C,347C,518C 'minimagick.cli':265C,504C,512C 'minimum':611C 'mitig':435C 'movement':147C 'msl':280C,614C 'must':451C,483C,527C 'name':171C 'none':184C 'normal':632C 'older':463C 'one':213C,227C,245C 'packag':426C 'parti':577C 'patch':634C 'path':263C,324C 'pdf':480C 'polici':255C,277C,328C,334C,340C,362C,411C,421C,459C,525C,535C,541C,594C,605C 'policy.xml':320C,499C 'postscript':478C 'prefix':513C 'prepend':257C 'preview':221C 'process':89C,122C,270C,387C,561C 'processor':391C,447C 'rail':86C 'rais':469C 'rather':175C,335C 're':485C 're-allow':484C 'read':115C,286C,539C 'readabl':118C,557C 'receiv':522C 'refer':298C 'releas':624C,627C 'remot':142C,295C 'render':477C 'replac':337C,503C 'report':233C 'requir':226C,380C,460C 'retain':581C 'rule':530C,591C 'run':193C,348C,406C 'screen':303C 'script':281C 'search':323C 'secret':127C,551C,556C,584C 'secur':254C,361C,410C 'see':355C 'select':153C 'server':104C 'servic':113C,549C 'shell':519C 'ship':251C,327C,524C,599C 'spawn':273C 'specif':228C 'storag':182C,354C,366C,385C,570C 'store':109C,545C 'suffici':218C 'system':134C,150C,534C,604C 'third':576C 'third-parti':575C 'togeth':309C 'token':578C 'turn':138C 'typic':125C 'ubuntu':425C 'unauthent':96C 'untrust':433C 'upgrad':436C,639C 'upload':204C,216C,431C 'us':235C 'use':381C,452C,494C 'user':434C 'variant':220C,446C 'version':250C,440C,598C 'whose':445C 'workaround':588C 'write':99C 'xml':623C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-04T00:00:00+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-f3w6-w445-fwh9","url":"https://github.com/rails/rails/security/advisories/GHSA-f3w6-w445-fwh9","severity":"critical","published_at":"2026-11-04T03:09:06+00:00","modified_at":"2026-11-04T03:09:06+00:00","first_seen_at":"2026-11-09T22:53:28+00:00","fetched_at":"2026-11-09T22:53:28+00:00","note":null}],"documents":[{"id":67032,"url":"https://thehackernews.com/2026/11/critical-rails-flaw-lets-attackers.html","title":"Critical Rails Flaw Lets Attackers Write Server Files via Crafted ImageMagick Uploads","kind":"blog","source":"analyst","publisher":null,"text":"Rails Active Storage GHSA-f3w6-w445-fwh9 (CVSS 9.8, no CVE): unauthenticated arbitrary file write via ImageMagick analyzer on attach (SVG reaching MSL coder); arbitrary file read with Disk service (secret_key_base, credentials). Affected: Active Storage < 8.0.5.2 and 8.1 < 8.1.4.1 using :mini_magick (default for load_defaults <= 6.1), without an ImageMagick policy blocking the coders (Debian/Ubuntu policies do not), accepting untrusted uploads. Fixed 8.1.4.1 / 8.0.5.2 (needs mini_magick >= 5.1); <8.0 unsupported. Also GHSA-v924-7rp8-4mxh (8.8) FFmpeg/ImageMagick decoder chosen by filename extension. Reported by RyotaK (GMO Flatt Security). Exploitation not stated.","published_at":"2026-11-04T00:00:00+00:00","relation":"mentions","confidence":null,"note":null},{"id":91449,"url":"https://x.com/feross/status/2118863523702874471","title":"@feross: We shipped a free Certified Patch for the 9.8 Rails Active Storage flaw. It clos","kind":"post","source":"x","publisher":null,"text":"We shipped a free Certified Patch for the 9.8 Rails Active Storage flaw. It closes the hole without a Rails upgrade. Free for anyone, @SocketSecurity customer or not.\n\nsocket patch add GHSA-f3w6-w445-fwh9\n\nPatch today. Then plan the upgrade.\n\nhttps://t.co/YXS800nXM1\n\nlikes 8 reposts 3","published_at":"2026-11-07T00:30:05+00:00","relation":"discussion","confidence":null,"note":"@feross"},{"id":67842,"url":"https://github.com/rails/rails/security/advisories/GHSA-f3w6-w445-fwh9","title":"Vendor advisory: github.com","kind":"vendor","source":"nvd","publisher":"vendor","text":null,"published_at":"2026-11-04T03:09:06+00:00","relation":"advisory","confidence":null,"note":"Maintainer's advisory: github.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}