# Cwe 780 Rsa Without Oaep

> Use this skill when you need to remediate CWE-780 (RSA Without OAEP Padding) vulnerabilities in Java code. Triggers on SAST findings, security reviews, or when fixing rsa without oaep padding issues.

- Skill: `developerscoffee/cwe-780-rsa-without-oaep` (Agent Skill)
- Install (CLI): `npx skillmds@latest add developerscoffee/cwe-780-rsa-without-oaep`
- Raw SKILL.md: https://api.skillmd.com/api/skills/developerscoffee/cwe-780-rsa-without-oaep/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- License: MIT
- Author: DevelopersCoffee (https://skillmd.com/u/developerscoffee)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/developerscoffee/cwe-780-rsa-without-oaep

---


# CWE-780 RSA Without OAEP Padding

## Description

RSA Without OAEP Padding

Reference:
https://cwe.mitre.org/data/definitions/780.html


**OWASP Category**: A02:2021 – Cryptographic Failures


---

## Vulnerable Pattern


### ❌ Example 1: Vulnerable Pattern

```java
// VULNERABLE: PKCS1 padding is susceptible to padding oracle attacks
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encrypted = cipher.doFinal(plaintext);
```


**Why it's vulnerable:** This pattern is vulnerable to RSA Without OAEP Padding




---

## Deterministic Fix


### ✅ Secure Implementation: Secure Implementation

```java
// SECURE: Use OAEP padding
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encrypted = cipher.doFinal(plaintext);

// Or with explicit OAEP parameters
OAEPParameterSpec oaepParams = new OAEPParameterSpec(
    "SHA-256",
    "MGF1",
    MGF1ParameterSpec.SHA256,
    PSource.PSpecified.DEFAULT
);
cipher.init(Cipher.ENCRYPT_MODE, publicKey, oaepParams);
```


**Why it's secure:** Implements proper protection against RSA Without OAEP Padding




---

## Detection Pattern

Look for these patterns in your codebase:


```bash
# Find RSA with weak padding
grep -rn "RSA.*PKCS1\|RSA/ECB/PKCS1" --include="*.java"
```



---

## Remediation Steps


1. Replace PKCS1Padding with OAEPWithSHA-256AndMGF1Padding

2. Use SHA-256 or stronger for OAEP hash

3. Consider using hybrid encryption (AES + RSA)


---

## Key Imports

```java

import javax.crypto.Cipher;

import javax.crypto.spec.OAEPParameterSpec;

```

---

## Verification

After remediation:


- Run SAST scanner to confirm vulnerability is resolved

- Review all instances of the vulnerable pattern

- Add unit tests that verify the secure implementation

- Check for similar patterns in related code


---

## Trigger Examples

```
Fix CWE-780 vulnerability
Resolve RSA Without OAEP Padding issue
Secure this Java code against rsa without oaep padding
SAST reports CWE-780
```

---

## Common Vulnerable Locations

| Layer | Files | Patterns |
|-------|-------|----------|

| Controller | `*Controller.java` | User input handling |

| Service | `*Service.java` | Business logic |

| Repository | `*Repository.java` | Data access |


---

## References


- [CWE-780: RSA Without OAEP](https://cwe.mitre.org/data/definitions/780.html)


---

**Source**: Generated by [Java CWE Security Skills Generator](https://github.com/DevelopersCoffee/java-cwe-security-skills)
**Last Updated**: 2026-03-07

