Some build dependencies are downloaded over an insecure channel (without subsequent integrity checks)
Two build jobs in OpenVPN's Travis CI configuration download dependencies over HTTP without integrity checks. An attacker in the network path could tamper with the downloads and inject malicious code into the build artifacts.
Originally disclosed on HackerOne
- Paid in 13 days
- Disclosed after 14 days
Summary:
Build jobs mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u download dependencies from build.openvpn.net and www.oberhumer.comover an insecure channel (http, not https) and do not check their integrity in any way.
This opens the door to person-in-the-middle attacks, whereby an attacker controlling an intermediate node on the network path between Travis CI's build servers and those two servers could manipulate traffic and inject his own malicious code into the artifacts produced by the two jobs in question.
Steps To Reproduce:
The install phase of the .travis.yml file unconditionally executes the .travis/build-deps.sh script. If the following three conditions are satisfied,
- the OS be other than
windows, - environment variable
SSLLIBbe set toopenssl, and - environment variable
CHOSTbe set,
(they are only satisfied for build jobs mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u), then shell functions download_tap_windows and download_lzo are executed one after the other.
Shell functions download_tap_windows and download_lzo are defined above (here and here, respectively) in .travis/build-deps.sh:
download_tap_windows () {
if [ ! -f "download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip" ]; then
wget -P download-cache/ \
"http://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip"
fi
}
download_lzo () {
if [ ! -f "download-cache/lzo-${LZO_VERSION}.tar.gz" ]; then
wget -P download-cache/ \
"http://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz"
fi
}
Note that both wget commands use http as opposed to https ( though using https is readily possible, since both domains build.openvpn.net and www.oberhumer.com support https and have valid TLS certificates) .
Supporting Material/References:
To be added in a comment below when my custom build of OpenVPN/openvpn finishes on travis-ci.org (it's taking a while...).
Impact
The two dependencies are downloaded over an insecure channel and, therefore, can be intercepted and tampered with by a person in the middle (controlling an intermediate node on the network path between Travis CI's build servers).
Moreover, as no integrity checks seem to be performed after download, a person-in-the-middle attack would go undetected and could seriously compromise the integrity of the artifacts produced by those two build jobs.
Please do not dismiss the possibility of such an attack too quickly, as it is not as far-fetched as one would think.
Context
OpenVPN's repository builds its Windows binaries on Travis CI. The build configuration lives in .travis.yml, and the heavy lifting for dependencies is delegated to .travis/build-deps.sh. Two of the build jobs, mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u, need extra dependencies that are not part of the base image: a TAP-Windows driver package and an LZO source tarball. The build script fetches both of them at build time.
The report is about how those two downloads are performed. Both are fetched with wget over plain http, and nothing checks what comes back.
Setup
No special account or tooling is needed to see the problem: the relevant files are public in the OpenVPN repository. The researcher refers to the following locations in the repository:
.travis.yml, lines 87 and 91, where the two affected jobs are defined..travis.yml, line 120, where theinstallphase runs the dependency script..travis/build-deps.sh, lines 4, 18, 148, 161, 162 and 165, which hold the conditions and the download functions.
The build platform is Travis CI (travis-ci.org). The two remote hosts involved are build.openvpn.net and www.oberhumer.com.
Finding it
The install phase of .travis.yml unconditionally executes .travis/build-deps.sh. Inside that script, the two download functions only run when three conditions are all satisfied:
- the OS is other than
windows; - the environment variable
SSLLIBis set toopenssl; - the environment variable
CHOSTis set.
According to the researcher, those conditions hold only for the two jobs mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u. For those jobs, the shell functions download_tap_windows and download_lzo are executed one after the other.
The two functions are defined earlier in .travis/build-deps.sh:
download_tap_windows () {
if [ ! -f "download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip" ]; then
wget -P download-cache/ \
"http://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip"
fi
}
download_lzo () {
if [ ! -f "download-cache/lzo-${LZO_VERSION}.tar.gz" ]; then
wget -P download-cache/ \
"http://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz"
fi
}
Both wget invocations use http, not https. The researcher points out that switching to https would be straightforward, because both build.openvpn.net and www.oberhumer.com support https and present valid TLS certificates. The only guard in each function is a check that the file is not already present in download-cache/; there is no checksum, signature or other integrity verification after the download.
Exploitation
Step 1: Identify the jobs that reach the download code
Read .travis.yml and confirm that the install phase runs .travis/build-deps.sh for every job. Then read the script and note the three conditions that gate the download functions. Only the mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u jobs satisfy all three, so only those two jobs fetch the two dependencies.
Step 2: Inspect how the dependencies are fetched
Look at download_tap_windows and download_lzo. Each builds a URL from a version variable (TAP_WINDOWS_VERSION and LZO_VERSION) and passes it to wget -P download-cache/. The scheme in both URLs is http. The -P download-cache/ option only sets the destination directory; it does not add any verification.
Step 3: Confirm there is no integrity check
After wget returns, the script does nothing with the file beyond leaving it in download-cache/. There is no hash comparison, no signature check and no pinned checksum in the script. A modified file would be used by the rest of the build exactly like the genuine one.
Step 4: Reason about the attack
Because the traffic is unencrypted and unauthenticated, an attacker who controls an intermediate node on the network path between Travis CI's build servers and build.openvpn.net or www.oberhumer.com can manipulate the traffic and substitute their own content. The build then compiles and packages that content, so the malicious code ends up inside the artifacts produced by the two jobs. Since nothing verifies the download afterwards, the substitution would go undetected.
The researcher notes that supporting material, a custom build of OpenVPN/openvpn on travis-ci.org, was still running at the time of writing and would be added in a comment.
Root cause
The mistake is the use of http for fetching build inputs that are then trusted, combined with the absence of any integrity check on the downloaded files. TLS would have provided both confidentiality and authentication of the two servers, and both servers already supported it with valid certificates. Neither was in place, so the only thing standing between the build and tampered input was the network path itself.
Impact
A person in the middle, controlling an intermediate node on the network path between Travis CI's build servers and the two download hosts, can intercept and tamper with the two dependencies. Because no integrity checks are performed after download, such an attack would go undetected and could seriously compromise the integrity of the artifacts produced by the two affected build jobs. The researcher stresses that this is not as far-fetched as it may sound, linking to a write-up about a man-in-the-middle attack against the Java ecosystem.
The impact is bounded by the conditions above: it applies to the mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u jobs, and to whoever consumes the artifacts those jobs produce.
Fix
The report does not describe a fix that was applied. It notes that fetching both dependencies over https would be straightforward, since both hosts support it with valid certificates.
Variants to test
- A positive result is a build input fetched over plain HTTP from a host that also serves HTTPS.
- A positive result is a fetched archive that is unpacked and used directly.
- A positive result is a cache check that trusts whatever is already on disk without verifying it.
- A positive result is a valid certificate on the HTTPS endpoint, which makes the plain HTTP fetch unnecessary.
Hunting notes
What happened, in plain words
OpenVPN is a well-known piece of software that lets you create a private, encrypted connection between your computer and another network. Like most software, it is built automatically: a service called Travis CI takes the source code, runs a series of commands, and produces the finished files that people download and install. This automatic building is called a build job.
Some build jobs need extra pieces that are not part of the standard setup. In this case two of them need a driver package called TAP-Windows and the source code of a compression library called LZO. The build script downloads these two pieces from the internet each time it runs.
The problem is how it downloads them. It uses a tool called wget and asks for the files over plain http, the unencrypted version of the web. Anyone sitting on the network path between the build servers and the servers hosting those files can quietly swap the real file for a malicious one. Nothing in the build checks afterwards that the file is the genuine article, so the swapped file would be compiled into the finished OpenVPN build and nobody would notice.
Context
To follow this, you need a few ideas first.
- A repository is a folder of source code hosted online, usually on a site like GitHub, where anyone can read it. OpenVPN keeps its code in such a repository.
- A build is the process of turning source code into a runnable program. It is done by a machine, not a person, and it follows written instructions.
- A build job is one task inside a build. A project may have many jobs, each producing a different version of the program, for example one for 64-bit Windows and one for 32-bit Windows.
- A dependency is an outside piece of software that the project needs in order to build. Think of a recipe that says "use a jar of tomato sauce": you did not make the sauce, you bought it, and you trust the shop.
- Travis CI is a service that runs build jobs for you on its own servers whenever the code changes. The report refers to it as
travis-ci.org.
OpenVPN's repository builds its Windows binaries on Travis CI. The build configuration lives in a file called .travis.yml, and the heavy lifting for dependencies is delegated to a script called .travis/build-deps.sh. Two of the build jobs, mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u, need extra dependencies that are not part of the base image: a TAP-Windows driver package and an LZO source tarball. The build script fetches both of them at build time.
The report is about how those two downloads are performed. Both are fetched with wget over plain http, and nothing checks what comes back.
Setup
No special account or tooling is needed to see the problem: the relevant files are public in the OpenVPN repository. The researcher refers to the following locations in the repository:
.travis.yml, lines 87 and 91, where the two affected jobs are defined..travis.yml, line 120, where theinstallphase runs the dependency script..travis/build-deps.sh, lines 4, 18, 148, 161, 162 and 165, which hold the conditions and the download functions.
The build platform is Travis CI (travis-ci.org). The two remote hosts involved are build.openvpn.net and www.oberhumer.com.
A word on the file names: a name starting with a dot, like .travis.yml, is simply a hidden file on Unix-like systems. The .yml ending means it is written in YAML, a format for configuration that humans can read. The .sh ending means it is a shell script, a list of commands that a computer runs in order, like a to-do list for the machine.
Finding it
The install phase of .travis.yml unconditionally executes .travis/build-deps.sh. "Unconditionally" means it happens every time, for every job, with no exception. Inside that script, the two download functions only run when three conditions are all satisfied:
- the OS is other than
windows; - the environment variable
SSLLIBis set toopenssl; - the environment variable
CHOSTis set.
An environment variable is a named setting that the build machine passes to the script, a bit like a label stuck on a box telling the script what is inside. SSLLIB here names which SSL library to use, and CHOST names the target platform the build is aimed at.
According to the researcher, those conditions hold only for the two jobs mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u. For those jobs, the shell functions download_tap_windows and download_lzo are executed one after the other.
A shell function is a small named block of commands inside a script. Instead of writing the same commands again and again, you give them a name and call that name when you need them.
The two functions are defined earlier in .travis/build-deps.sh:
download_tap_windows () {
if [ ! -f "download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip" ]; then
wget -P download-cache/ \
"http://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip"
fi
}
download_lzo () {
if [ ! -f "download-cache/lzo-${LZO_VERSION}.tar.gz" ]; then
wget -P download-cache/ \
"http://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz"
fi
}
Line by line, in plain words:
download_tap_windows () {starts the definition of a function nameddownload_tap_windows. Everything between the braces belongs to it.if [ ! -f "download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip" ]; thenasks a question: is there no file at that path? The!means "not", and-fmeans "a regular file exists". So the answer is yes only when the file is missing.${TAP_WINDOWS_VERSION}is replaced by whatever version number the build has been given.wget -P download-cache/ \runs the download toolwget. The-P download-cache/part tells it to save the file into thedownload-cache/folder. The backslash at the end means the command continues on the next line."http://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip"is the address being downloaded. Notice the scheme:http, nothttps.ficloses theifquestion, and}closes the function.- The second function,
download_lzo, works the same way, but fetches an LZO archive fromwww.oberhumer.cominstead.
Both wget invocations use http, not https. The researcher points out that switching to https would be straightforward, because both build.openvpn.net and www.oberhumer.com support https and present valid TLS certificates. The only guard in each function is a check that the file is not already present in download-cache/; there is no checksum, signature or other integrity verification after the download.
Here is what those security words mean, from zero:
- HTTP is the language browsers and servers use to exchange pages and files. In its plain form, everything travels in the clear, like a postcard anyone handling the mail can read.
- HTTPS is the same language wrapped in encryption. It is like a sealed envelope: people can see that a letter is going somewhere, but not what is inside, and they cannot swap the contents without breaking the seal.
- TLS is the technology that does the sealing. A TLS certificate is a digital proof, issued by a trusted authority, that a server really is who it claims to be. Both hosts here have valid ones, so the sealed option was available all along.
- A checksum is a short fingerprint computed from a file's contents. If even one byte changes, the fingerprint changes. Comparing the fingerprint after download against a known good one proves the file is intact.
- A signature is a cryptographic stamp proving a file came from the expected author and was not altered.
- Integrity simply means "the file is exactly what it is supposed to be, unchanged".
Exploitation
Step 1: Identify the jobs that reach the download code
Read .travis.yml and confirm that the install phase runs .travis/build-deps.sh for every job. Then read the script and note the three conditions that gate the download functions. Only the mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u jobs satisfy all three, so only those two jobs fetch the two dependencies.
Why this step matters: before claiming a problem, you need to know exactly which builds are affected. A download that never runs is harmless. Tracing the conditions narrows the impact from "the whole project" to two specific jobs.
Step 2: Inspect how the dependencies are fetched
Look at download_tap_windows and download_lzo. Each builds a URL from a version variable (TAP_WINDOWS_VERSION and LZO_VERSION) and passes it to wget -P download-cache/. The scheme in both URLs is http. The -P download-cache/ option only sets the destination directory; it does not add any verification.
Why this step matters: the scheme in the address is the whole story. http means the file travels unprotected, and the wget options chosen do nothing to compensate.
Step 3: Confirm there is no integrity check
After wget returns, the script does nothing with the file beyond leaving it in download-cache/. There is no hash comparison, no signature check and no pinned checksum in the script. A modified file would be used by the rest of the build exactly like the genuine one.
Why this step matters: encryption and integrity checks are two separate defences. Even if the download were over http, a checksum would catch a swapped file. Here neither defence is present, so there is nothing to catch a substitution.
Step 4: Reason about the attack
Because the traffic is unencrypted and unauthenticated, an attacker who controls an intermediate node on the network path between Travis CI's build servers and build.openvpn.net or www.oberhumer.com can manipulate the traffic and substitute their own content. The build then compiles and packages that content, so the malicious code ends up inside the artifacts produced by the two jobs. Since nothing verifies the download afterwards, the substitution would go undetected.
An intermediate node is any machine the traffic passes through on its way: a router, a proxy, a Wi-Fi access point. A person in the middle is an attacker who sits on one of those machines and can read or change what passes. "Unauthenticated" means the build never proves it is really talking to the genuine server, so a fake server or a tampering middleman is not noticed.
The researcher notes that supporting material, a custom build of OpenVPN/openvpn on travis-ci.org, was still running at the time of writing and would be added in a comment.
Root cause
The mistake is the use of http for fetching build inputs that are then trusted, combined with the absence of any integrity check on the downloaded files. TLS would have provided both confidentiality and authentication of the two servers, and both servers already supported it with valid certificates. Neither was in place, so the only thing standing between the build and tampered input was the network path itself.
A useful comparison: buying ingredients for a restaurant kitchen from a supplier who hands them over in an open basket on the street, with no receipt and no seal, and then cooking with whatever is in the basket. If someone swapped the basket on the way, the kitchen would never know.
Impact
A person in the middle, controlling an intermediate node on the network path between Travis CI's build servers and the two download hosts, can intercept and tamper with the two dependencies. Because no integrity checks are performed after download, such an attack would go undetected and could seriously compromise the integrity of the artifacts produced by the two affected build jobs. The researcher stresses that this is not as far-fetched as it may sound, linking to a write-up about a man-in-the-middle attack against the Java ecosystem.
The impact is bounded by the conditions above: it applies to the mingw64 | openssl-1.1.1d and mingw32 | openssl-1.0.2u jobs, and to whoever consumes the artifacts those jobs produce.
In everyday terms: if someone slips a malicious file into the build, the artifacts produced by those two jobs could contain that code, and the tampering would go undetected.
Fix
The report does not describe a fix that was applied. It notes that fetching both dependencies over https would be straightforward, since both hosts support it with valid certificates.
Variants to test
- A positive result is a build input fetched over plain HTTP from a host that also serves HTTPS.
- A positive result is a fetched archive that is unpacked and used directly.
- A positive result is a cache check that trusts whatever is already on disk without verifying it.
- A positive result is a valid certificate on the HTTPS endpoint, which makes the plain HTTP fetch unnecessary.
Hunting notes
Glossary
- Build: the automated process of turning source code into a runnable program.
- Build job: one task within a build, often producing one particular version of the program.
- CI (continuous integration): a service that automatically builds and tests code whenever it changes.
- Travis CI: the CI service used by OpenVPN in this report, referred to as
travis-ci.org. - Repository: an online folder of source code, usually on a site such as GitHub.
- Dependency: an outside piece of software that a project needs in order to build or run.
.travis.yml: the configuration file that tells Travis CI what to do..travis/build-deps.sh: the shell script that downloads and prepares dependencies for the build.- Shell script: a text file of commands that a computer runs in order.
- Shell function: a named block of commands inside a script, called by its name.
- Environment variable: a named setting passed to a script by the machine running it.
wget: a command-line tool for downloading files from the internet.curl: another command-line tool for transferring data over the network.- HTTP: the unencrypted protocol used to exchange pages and files on the web.
- HTTPS: HTTP wrapped in encryption, so traffic cannot be read or altered unnoticed.
- TLS: the encryption technology behind HTTPS.
- TLS certificate: a digital proof, issued by a trusted authority, that a server is who it claims to be.
- Checksum / hash: a short fingerprint of a file's contents, used to detect any change.
- Signature: a cryptographic stamp proving a file's origin and that it was not altered.
- Integrity: the property of a file being exactly what it is supposed to be, unchanged.
- Integrity check: any step that verifies a downloaded file is genuine, such as a checksum or signature comparison.
- Person in the middle (MITM): an attacker who sits on a machine along the network path and can read or change traffic.
- Intermediate node: any machine traffic passes through on its way, such as a router or proxy.
- Unauthenticated: without proof that you are really talking to the genuine party.
- Confidentiality: keeping data unreadable to anyone who is not supposed to see it.
- Authentication: proving that a party is who it claims to be.
- Artifact: the finished file or package produced by a build job.
- Tarball: a single archive file containing several files, often compressed.
- TAP-Windows: a Windows driver package needed by some OpenVPN build jobs.
- LZO: a compression library whose source code is downloaded during the build.
- CVSS: a standard scoring system for rating the severity of a security issue.
- Bounty: a payment made to a researcher who reports a valid security issue.
- Disclosure: the moment a security report is made public.