# GHSA-jq42-hfch-42f3: Action Commands (run/shell/exec) Against Library URIs Ignore Configured Remote Endpoint

> Attackers can execute malicious containers by exploiting a bug where Singularity ignores configured remote endpoints for library URIs, requiring user interaction to run the container.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 1 Jun 2021

## What is GHSA-jq42-hfch-42f3?

GHSA-jq42-hfch-42f3 is a vulnerability in github.com/hpcng/singularity, published on 1 Jun 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

# Impact
Due to incorrect use of a default URL, `singularity` action commands (`run`/`shell`/`exec`) specifying a container using a `library://` URI will always attempt to retrieve the container from the default remote endpoint (`cloud.sylabs.io`) rather than the configured remote endpoint.

An attacker may be able to push a malicious container to the default remote endpoint with a URI that is identical to the URI used by a victim with a non-default remote endpoint, thus executing the malicious container.

Only action commands (`run`/`shell`/`exec`) against `library://` URIs are affected. Other commands such as `pull` / `push` respect the configured remote endpoint.

# Patches
All users should upgrade to Singularity 3.7.4 or later.

# Workarounds
Users who only interact with the default remote endpoint or do not use the library:// url are not affected.

Installations with an execution control list configured to restrict execution to containers signed with specific secure keys are not affected.

# Acknowledgements
This issue was found by Mike Frisch and brought to our attention by Sylabs.  Sylabs is making a [coordinated disclosure](https://github.com/sylabs/singularity/security/advisories/GHSA-5mv9-q7fq-9394).

# For more information
General questions about the impact of the advisory can be asked in the:

[Singularity Slack Channel](https://join.slack.com/t/hpcng/shared_invite/zt-qda4h1ls-OP0Uouq6sSmVE6i_0NrWdw)
[Singularity Mailing List](https://groups.google.com/a/lbl.gov/g/singularity)
Any sensitive security concerns should be directed to: [singularity-security@hpcng.org](mailto:singularity-security@hpcng.org)

## Which versions are affected by GHSA-jq42-hfch-42f3?

2 open source packages ship an affected version, including github.com/hpcng/singularity.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/hpcng/singularity` | Go | From 3.7.2 | 3.7.4 |
| `github.com/hpcng/singularity` | Go | From 3.7.2 | 3.7.4 |

## How do I fix GHSA-jq42-hfch-42f3?

Upgrade github.com/hpcng/singularity to 3.7.4 or later.

## Is GHSA-jq42-hfch-42f3 being exploited?

There is no known exploitation of GHSA-jq42-hfch-42f3 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-jq42-hfch-42f3 and fix it if it is affected.

What it is: GHSA-jq42-hfch-42f3 is a vulnerability in github.com/hpcng/singularity, published on 1 Jun 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-jq42-hfch-42f3 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/hpcng/singularity (Go): affected from 3.7.2; fixed in 3.7.4
- github.com/hpcng/singularity (Go): affected from 3.7.2; fixed in 3.7.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-jq42-hfch-42f3/ (Markdown: https://insights.sbomify.com/GHSA-jq42-hfch-42f3/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-jq42-hfch-42f3

---
From sbomify Insights: https://insights.sbomify.com/GHSA-jq42-hfch-42f3/
Summaries are generated and may contain mistakes; the official description above is the record.
