Impact
A malicious package can introduce arbitrary JavaScript code into the Hydra database that is automatically evaluated in a client's browser when anyone (including administrators) visits the build page.
While this would be very obvious in a Nix package definition, this could be done by a third-party project as part of its build process. The only thing that has to be done is writing to $out/nix-support/hydra-metrics
.
The vulnerability exposes two places where the output parsing logic is flawed. First, data is taken as-is without further validation and written to the database. When rendering the build page, the data is again taken as-is from the database and directly embedded into the page. This also happens in other places like with hydra-release-name
.
Patches
Apply dea1e16 to your Hydra package.
Workarounds
Either not building untrusted packages or not visiting the builds page.
Additional information
After a build, Hydra reads these files:
$out/nix-support/failed
$out/nix-support/hydra-build-products
$out/nix-support/hydra-release-name
$out/nix-support/hydra-metrics
There was no or improper validation for all of these files except the first one. During the fix of the issue, a lot of escaping was introduced into the templates in unrelated places to prevent future similar issues and provide defense in depth.
Impact
A malicious package can introduce arbitrary JavaScript code into the Hydra database that is automatically evaluated in a client's browser when anyone (including administrators) visits the build page.
While this would be very obvious in a Nix package definition, this could be done by a third-party project as part of its build process. The only thing that has to be done is writing to
$out/nix-support/hydra-metrics
.The vulnerability exposes two places where the output parsing logic is flawed. First, data is taken as-is without further validation and written to the database. When rendering the build page, the data is again taken as-is from the database and directly embedded into the page. This also happens in other places like with
hydra-release-name
.Patches
Apply dea1e16 to your Hydra package.
Workarounds
Either not building untrusted packages or not visiting the builds page.
Additional information
After a build, Hydra reads these files:
$out/nix-support/failed
$out/nix-support/hydra-build-products
$out/nix-support/hydra-release-name
$out/nix-support/hydra-metrics
There was no or improper validation for all of these files except the first one. During the fix of the issue, a lot of escaping was introduced into the templates in unrelated places to prevent future similar issues and provide defense in depth.