Skip to content
RCE Write-up Advanced

(CVE-2021-0219) Juniper Junos OS validate package mgd_package_real() command injection

A command injection flaw exists in Junos OS when validating a software package before installation. An attacker with low privileges could execute commands with root privileges.

starlabs.sg

Published on starlabs.sg

The command injection vulnerability exists in the validation of the installed package. Upon successfully exploiting this vulnerability, an attacker with low privilege can execute a command with root privilege in the system.

The author, on starlabs.sg

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the package validation routine passes user-controlled package data into a shell command without proper sanitisation.

What the attacker needed

Low-privilege access to the CLI; ability to supply a crafted package

How it was found

  1. Run the CLI command to validate a package on the host before installing.
  2. The mgd_package_real() function in libjunos-actions-impl.so is called.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you ask the router to check a software package before installing it, the router runs a helper program that builds a shell command from parts of the package. If those parts are not cleaned properly, an attacker who can supply a crafted package can make the router run extra commands as the all-powerful root user.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.