GHSA-4vc8-wvhw-m5gv CVE-2025-0928 GO-2025-3805
Juju allows arbitrary executable uploads via authenticated endpoint without authorization
- Severity
- 8.8 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 0.69%
- Chance of exploitation in the next 30 days. Higher than 52.99% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
0.0.0-20250619215741-4034aa13c7cf- Upgrade github.com/juju/juju to this version or later
Description
Summary
You can affect the agent binaries used in a Juju controller and the code that is run in the binaries by simply having a user account on a controller. You aren't required to have a model or any permissions. This just requires a user account in the controller database.
Details
Because of the way Juju upload tools code works in the controller it only checks that the user uploading agent binaries is authenticated and is a user tag. No more checks are performed and it allows that user to upload binaries to any model they like (as long as they know the model uuid) or upload binaries to the controller (attacker doesn't need to know any uuid's for controller or controller model).
Once the poison binaries have been uploaded any new machine that is started in the affected model or controller will get started with the poison binaries. Alternatively administrator's of the controller running either juju upgrade-controller or juju upgrade-model will force distribution of the poisoned binaries to all machines in either the model or poison the controllers themselves.
On top of this the exploit can be done with the Juju client tooling itself and no real knowledge on constructing raw API requests is required.
The tools handler is the main piece of code that is used in the APIServer for handling upload requests and persisting the data uploaded: The following code references is how Juju uses and defines this:
- The tools upload handler is defined here (https://github.com/juju/juju/blob/3.6/apiserver/apiserver.go#L972)
- The tools upload handler is created in the api server here (https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L766C2-L766C25).
- The main authoriser that is used for the upload handler is created here (https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L770C2-L770C28)
- The upload handler is registered for the model here (https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L902)
- The upload handler is registered for the controller here (https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L972)
The authoriser that is used (https://github.com/juju/juju/blame/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/httpcontext.go#L209) only confirms that the logged in user is authenticated and authenticated as a user tag. No other checks are performed.
The toolsUploaderHandler also uses another server func for getting the Mongo state. This also confirms a logged in user but the state that is returned to the caller is scoped to whatever model the requester has asked for. No checks are performed to make sure that the user in question actually has access to this model or the controller. See code here (https://github.com/juju/juju/blob/4e50a28cdde17832aa31634915fbe7442dca6ab3/apiserver/httpcontext.go#L38). We end up here through a few layers of indirection of https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L768
We can also see that when handlers are registered with no model uuid scope in the handler like the controller registration of the tools upload handler, the model uuid gets defaulted to that of the controller model. See (https://github.com/juju/juju/blob/4bcbd094097016b2fde926afd8c9e590eabb3f0c/apiserver/apiserver.go#L690).
PoC
This proof of concept was done with the latest tip of the juju/juju 3.6 branch (https://github.com/juju/juju/commit/cd12b4951d657a980e113564bf2ea82f167589fd). Pull this code and work from inside of the root of the code base. It is expected that this security issue applies to 2.9 onwards as well.
Repo steps:
-
Bootstrap a new controller to lxd. This was done with a compiled client from the branch but there is no reason performing this action from latest snap won't produce the same result.
juju bootstrap localhost sec-demo -
Add a new user to the controller. This is the user with no permissions or models that we will prove the problem with.
juju add-user poisoner poisoner -
From step 2 save the registration string that the
jujuclient prints out. -
We are going to remove the local
jujuadmin credentials and information that was made during bootstrap. We will use this later on for confirming the attack.mv ~/.local/share/juju /tmp/juju-bak -
Run the
jujucli registration command for the new user that was saved from step 3. Set the new password to whatever you wish and then re-enter to login into the controller. After this step we are now logged in as an unprivileged user to the controller. -
Apply the following patch to the currently checked out
jujucode base:
cat <<EOF | git apply -
diff --git a/cmd/jujud/main.go b/cmd/jujud/main.go
index f268509a52..1b01a74b66 100644
--- a/cmd/jujud/main.go
+++ b/cmd/jujud/main.go
@@ -315,6 +315,16 @@ func Main(args []string) int {
os.Exit(exit_err)
}
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("Got access to the binary")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+ logger.Criticalf("----------------------")
+
var code int
commandName := filepath.Base(args[0])
switch commandName {
diff --git a/version/version.go b/version/version.go
index 2bbc8968c8..40af52f337 100644
--- a/version/version.go
+++ b/version/version.go
@@ -18,7 +18,7 @@ import (
// The presence and format of this constant is very important.
// The debian/rules build recipe uses this value for the version
// number of the release package.
-const version = "3.6.6"
+const version = "3.6.7"
// UserAgentVersion defines a user agent version used for communication for
// outside resources.
EOF
- Set bogus model information. To make the
sync-agent-binarycommand work below we need to set a bogus model that is in use by the client. This is done through the localmodels.yamlfile. Theuuidfeatured here does not matter at and can be set to anything that parses as a uuid injuju. This is just to trick the client tooling, the attacker could just manually construct the http request their self to bypass this.
cat <<EOF > ~/.local/share/juju/models.yaml
controllers:
sec-demo:
models:
admin/controller:
uuid: 4dde46dd-a514-491e-8a5f-b908b5310c02
type: iaas
branch: ""
current-model: admin/controller
EOF
- Next build the changes with
make simplestreams. - The output of step 9 will provide an export command to run. Please execute this command to point the
jujuclient at your local simple streams cache. - Next sync the compiled agent binaries from step 9 to the controller with
juju sync-agent-binary --debug --agent-version 3.6.7.
At this stage the controllers agent binary cache has been poisoned and the security issue has been proven.
- We can now swap back to the administrator user to start forcing binary circulation.
mv ~/.local/share/juju /tmp/juju-poisonand thenmv /tmp/juju-bak ~/.local/share/juju
At this stage the issue can be demonstrated with just a simple juju upgrade-controller and a controller upgrade will kick off. You can also upgrade a model. When I was testing this my upgrade-controller failed to shut down the controller for reasons unrelated to this security issue. I was able to log into the controller and confirm with sha256sum that the controller had downloaded the new binaries and the checksums matched. They were also symlink as the new binaries to run for machine-0. This was under /var/lib/juju/tools on the controller machine.
It would also be possible to affect new machines coming up in a model by repeating the steps above but changing the version to that of the model that you want to be poisoned.
Impact
This is a bad vulnerability in my opinion. It allows a user with no permissions to eventually consume an entire juju controller with poisoned binaries and gain access to all of the infrastructure and secrets on that controller. Through model migration it would also be possible to poison other controllers that the user doesn't have access to.
This also requires that an administrator upgrade or migrate aspects of the controller. But a bad actor could affect brand new machines coming up in the system straight away.
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/juju/juju | < 0.0.0-20250619215741-4034aa13c7cf |
0.0.0-20250619215741-4034aa13c7cf |
| github.com/juju/juju | all versions |
No fix yet |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/juju/juju Go → 0.0.0-20250619215741-4034aa13c7cf
- go
go get github.com/juju/juju@v0.0.0-20250619215741-4034aa13c7cf && go mod tidy
Severity breakdown
CVSS 3.1 8.8
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-285: Improper Authorization
The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.
How to prevent it
- Architecture and Design: Divide the product into anonymous, normal, privileged, and administrative areas. Reduce the attack surface by carefully mapping roles with data and functionality. Use role-based access control (RBAC) to enforce the roles at the appropriate boundaries. Note that this approach may not protect against horizontal authorization, i.e., it will not protect a user from attacking others with the same role.
- Architecture and Design: Ensure that you perform access control checks related to your business logic. These checks may be different than the access control checks that you apply to more generic resources such as files, connections, processes, memory, and database records. For example, a database may restrict access for medical records to a specific database user, but each record might only be intended to be accessible to the patient and the patient's doctor.
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using authorization frameworks such as the JAAS Authorization Framework [REF-233] and the OWASP ESAPI Access Control feature [REF-45].
- Architecture and Design: For web applications, make sure that the access control mechanism is enforced correctly at the server side on every page. Users should not be able to access any unauthorized functionality or information by simply requesting direct access to that page. One way to do this is to ensure that all pages containing sensitive information are not cached, and that all such pages restrict access to requests that are accompanied by an active and authenticated session token associated with a user who has the required permissions to access that page.
- System Configuration, Installation: Use the access control capabilities of your operating system and server environment and define your access control lists accordingly. Use a "default deny" policy when defining these ACLs.
CWE-434: Unrestricted Upload of File with Dangerous Type
The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.
How to prevent it
- Architecture and Design: Generate a new, unique filename for an uploaded file instead of using the user-supplied filename, so that no external input is used at all.[REF-422] [REF-423]
- Architecture and Design: When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
- Architecture and Design: Consider storing the uploaded files outside of the web document root entirely. Then, use other mechanisms to deliver the files dynamically. [REF-423]
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. For example, limiting filenames to alphanumeric characters can help to restrict the introduction of unintended file extensions.
- Architecture and Design: Define a very limited set of allowable extensions and only generate filenames that end in these extensions. Consider the possibility of XSS (CWE-79) before allowing .html or .htm file types.
- Implementation: Ensure that only one extension is used in the filename. Some web servers, including some versions of Apache, may process files based on inner extensions so that "filename.php.gif" is fed to the PHP interpreter.[REF-422] [REF-423]
- Implementation: When running on a web server that supports case-insensitive filenames, perform case-insensitive evaluations of the extensions that are provided.
- Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Implementation: Do not rely exclusively on sanity checks of file contents to ensure that the file is of the expected type and size. It may be possible for an attacker to hide code in some file segments that will still be executed by the server. For example, GIF images may contain a free-form comments field.
- Implementation: Do not rely exclusively on the MIME content type or filename attribute when determining how to render a file. Validating the MIME content type and ensuring that it matches the extension is only a partial solution.
- Architecture and Design, Operation: Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Architecture and Design, Operation: Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
References
Advisories
Packages
Other links
- github.com/juju/juju/security/advisories/GHSA-4vc8-wvhw-m5gv
- github.com/juju/juju/commit/22cdcf6b54c2f371822e1c203d4f341be6c9589e
- github.com/juju/juju/commit/311e374cb8d2431032c51fb3fb5c4b0aaaa7196c
- github.com/juju/juju/commit/4034aa13c7cf5a37427fcd032925d5d21955b096
- github.com/juju/juju/commit/b4176e6e45c2c3c817ab60b39e2d52f9a11a5ddf
- pkg.go.dev/vuln/GO-2025-3805
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-7m55-2hr4-pw78 Juju: In-Memory Token Store for Discharge Tokens Lacks Concurrency Safety and Persistence | Medium | Also affects github.com/juju/juju |
| GHSA-w5fq-8965-c969 Juju: CloudSpec method leaking cloud credentials | Medium | Also affects github.com/juju/juju |
| GHSA-245v-p8fj-vwm2 Juju has a resource poisoning vulnerability | Medium | Also affects github.com/juju/juju |
| GHSA-j6f6-jp3p-53mw Juju: Read All Controller Logs From Compromised Workload | Medium | Also affects github.com/juju/juju |
| GHSA-gvrj-cjch-728p Juju has Improper TLS Client/Server authentication and certificate verification on Database Cluster | Critical | Also affects github.com/juju/juju |
| GHSA-5cj2-rqqf-hx9p Juju affected by Confused Deputy IDOR attack via Predictable user specified ID in Juju Secrets | Medium | Also affects github.com/juju/juju |
| GHSA-439w-v2p7-pggc Juju has unauthorized access to out-of-scope Kubernetes secrets | High | Also affects github.com/juju/juju |
| GHSA-89x7-5m5m-mcmm Juju has unauthorized update of out-of-scope Vault secrets | Medium | Also affects github.com/juju/juju |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor