HerokuCraig IngramProblem & solution
Securing Dependencies for Rails 5.2 Active Storage
Summary
Supporting Rails 5.2 Active Storage on Heroku required handling media files for PDF and video previews while addressing FFmpeg’s security and packaging constraints. Ubuntu Trusty’s lack of FFmpeg support, Xenial’s community-maintained package and missing vulnerability backports, and concerns about Libav led the team to build its own binary. Using a fork of sffmpeg and modified CMake configuration, the team created a static FFmpeg build that removed non-free software and unused components such as RTMP and xvid, reducing dependencies and attack surface. Docker-based CircleCI automation compiles the binary, packages it as a Debian archive, uploads it to AWS S3, and lets the buildpack install it without root access. The resulting package is about 30MB instead of roughly 200MB and can be updated in around 20 minutes after upstream security releases.
Context
Heroku needed to support Rails 5.2 Active Storage previews for PDFs and videos. FFmpeg presented security and distribution challenges: Ubuntu Trusty did not support it, Xenial’s package lacked backports for several vulnerabilities, and Libav was described as having numerous unresolved bugs.
Approach / What changed
The team forked sffmpeg, modified its CMake configuration to remove non-free software and unused libraries, and built a static FFmpeg binary packaged as a Debian archive. Docker-based CircleCI automation compiles and uploads the package to AWS S3, while the Active Storage Preview buildpack extracts it into application dynos without root access.
Takeaways
The reduced static build is about 30MB, compared with roughly 200MB for FFmpeg and its default dependencies.
Removing unused components such as RTMP stream support and xvid reduces dependencies that would require security monitoring and could introduce vulnerabilities.
The automated CI build and upload process takes around 20 minutes, enabling rapid distribution of patches after upstream security releases.
Source and freshness
- Source
- heroku.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.