# GHSA-pgcr-7wm4-mcv6: Sensitive Data Exposure in pem

> Local attackers can read sensitive PKCS12 passwords from temporary files created by the pem library, exposing cryptographic keys.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Jun 2019

## What is GHSA-pgcr-7wm4-mcv6?

GHSA-pgcr-7wm4-mcv6 is a vulnerability in pem, published on 4 Jun 2019. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Versions of `pem` before 1.13.2 expose sensitive data when the `readPkcs12` is used. 

The `readPkcs12` function reads the certificate and key data from a pkcs12 file using the encryption password. As part of this process it creates a globally readable file with a filename of 20 random 0-f characters in the temporary directory containing the password which is then read by OpenSSL. The file containing the password is never cleaned up after it is used giving access to the pkcs12 password to any other users with access to read files from the system.

## Recommendation

Update to version 1.13.2 or later.

## Which versions are affected by GHSA-pgcr-7wm4-mcv6?

2 open source packages ship an affected version, including pem.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pem` | npm | All versions | 1.13.2 |
| `pem` | npm | All versions | 1.13.2 |

## How do I fix GHSA-pgcr-7wm4-mcv6?

Upgrade pem to 1.13.2 or later.

## Is GHSA-pgcr-7wm4-mcv6 being exploited?

There is no known exploitation of GHSA-pgcr-7wm4-mcv6 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-pgcr-7wm4-mcv6 and fix it if it is affected.

What it is: GHSA-pgcr-7wm4-mcv6 is a vulnerability in pem, published on 4 Jun 2019. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-pgcr-7wm4-mcv6 in the wild and no public exploit code.

Affected packages and fixed versions:
- pem (npm): affected all versions; fixed in 1.13.2
- pem (npm): affected all versions; fixed in 1.13.2

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-pgcr-7wm4-mcv6/ (Markdown: https://insights.sbomify.com/GHSA-pgcr-7wm4-mcv6/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-pgcr-7wm4-mcv6

---
From sbomify Insights: https://insights.sbomify.com/GHSA-pgcr-7wm4-mcv6/
Summaries are generated and may contain mistakes; the official description above is the record.
