Back to Blog
medium SEVERITY8 min read

HTTP Basic Auth Over Plain HTTP: How ESP32 Credentials Were Exposed on Your Wi-Fi

A medium-severity vulnerability in the ESP32-audioI2S library allowed audio streaming credentials to be transmitted via HTTP Basic Authentication over unencrypted HTTP connections, making them trivially recoverable by anyone on the same network. The fix gates the Authorization header behind an SSL/TLS check, ensuring credentials are only sent when the connection is encrypted. For embedded IoT devices where credentials are often hardcoded in firmware, this kind of passive interception risk is esp

O
By Orbis AppSec
Published May 28, 2026Reviewed June 3, 2026

Answer Summary

HTTP Basic Auth credential exposure (CWE-319) in ESP32-audioI2S allowed credentials to be transmitted in cleartext over unencrypted HTTP connections. In embedded Arduino/C++ IoT code, this is fixed by gating the Authorization header behind an SSL/TLS check—only sending credentials when `https://` is used—preventing passive Wi-Fi sniffing attacks that could recover hardcoded firmware credentials.

Vulnerability at a Glance

cweCWE-319
fixGate credential transmission behind SSL/TLS connection verification
riskNetwork attackers can passively intercept authentication credentials
languageC++/Arduino (ESP32)
root causeAuthorization header sent regardless of connection encryption status
vulnerabilityCleartext Transmission of Sensitive Information (HTTP Basic Auth over plain HTTP)

HTTP Basic Auth Over Plain HTTP: How ESP32 Credentials Were Exposed on Your Wi-Fi

Summary

A security vulnerability in the popular ESP32-audioI2S library (v3.0.6) allowed audio streaming server credentials to be silently leaked over the air. When connecting to a password-protected stream, the library would attach an Authorization: Basic header to the HTTP request — even when the connection was not encrypted. Any device passively sniffing traffic on the same Wi-Fi network could capture that header and decode the credentials in seconds. A one-line patch now ensures credentials are only sent over SSL/TLS-protected connections.


Introduction

If you've ever built an internet radio, a smart speaker, or a streaming audio project with an ESP32, there's a good chance you've used the ESP32-audioI2S library. It's a well-regarded, widely adopted library that handles the heavy lifting of connecting to audio streams, decoding formats, and pushing audio out over I2S to a DAC or amplifier.

Many audio streams — especially private or subscription-based ones — require authentication. The library supports this via HTTP Basic Authentication, a decades-old scheme where a username and password are Base64-encoded and attached to the HTTP request as a header.

Here's the problem: Base64 is not encryption. It's encoding. Anyone who captures the header can reverse it instantly. And if the HTTP connection itself isn't encrypted, that header travels across the network in plaintext, readable by any device within radio range.

For developers building hobby projects, this might sound academic. But in practice, IoT credentials are frequently:
- Hardcoded in firmware and difficult to rotate
- Reused across services (the same password used for the stream and for the user's email)
- Transmitted repeatedly on every connection attempt

This makes the exposure window wide and the consequences potentially serious.


The Vulnerability Explained

What Is HTTP Basic Authentication?

HTTP Basic Auth is defined in RFC 7617. When a client wants to authenticate, it sends a header like this:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

That long string is just username:password encoded in Base64. To decode it:

echo "dXNlcm5hbWU6cGFzc3dvcmQ=" | base64 --decode
# Output: username:password

That's it. No hashing. No encryption. No secret key. Anyone who sees the header has the credentials.

RFC 7617 itself explicitly states:

"This scheme is not considered to be a secure method of user authentication unless used in conjunction with some external secure system such as TLS."

What Was the Vulnerable Code Doing?

In Audio.cpp, the connecttohost() function builds an HTTP request and conditionally appends an Authorization header:

// BEFORE (vulnerable)
if (auth > 0) {
    strcat(rqh, "Authorization: Basic ");
    strcat(rqh, authorization);
    strcat(rqh, "\r\n");
}

The condition here only checks whether credentials were provided (auth > 0). It does not check whether the connection is using SSL/TLS. This means:

  • Connect to http://stream.example.com with credentials? → Header is sent in plaintext. ❌
  • Connect to https://stream.example.com with credentials? → Header is sent over TLS. ✅

Both cases triggered the same code path.

Real-World Attack Scenario

Imagine the following scenario:

  1. A developer builds a home audio player using an ESP32 and the audioI2S library.
  2. They subscribe to a private internet radio service that requires a username and password.
  3. They hardcode those credentials in their firmware and flash the device.
  4. The device sits on their home Wi-Fi network, connecting to http://radio.example.com every time it boots.

Now imagine a neighbor, a guest, or a compromised device on the same network runs a simple packet capture:

sudo tcpdump -i wlan0 -A port 80 | grep -i authorization

Within seconds of the ESP32 booting, they see:

Authorization: Basic dXNlcjpteXNlY3JldHBhc3N3b3Jk

Decoded: user:mysecretpassword

The attack requires no active intrusion, no brute forcing, no special tools beyond a laptop with Wi-Fi in monitor mode. It's entirely passive.

Why Is This Worse on Embedded Devices?

On a web application, if credentials are compromised, you can force a password reset. On an ESP32:

  • The credentials are likely compiled into the firmware binary
  • Updating firmware requires physical access or a working OTA pipeline
  • Users often don't know a compromise has occurred
  • The same credentials may protect other services

The blast radius of a single captured packet can be significant.


The Fix

The fix is elegant in its simplicity — a single additional condition:

// AFTER (fixed)
if (auth > 0 && m_f_ssl) {
    strcat(rqh, "Authorization: Basic ");
    strcat(rqh, authorization);
    strcat(rqh, "\r\n");
}

By adding && m_f_ssl, the Authorization header is now only appended when the connection is SSL/TLS-encrypted. If a caller tries to authenticate over a plain HTTP connection, the credentials are silently withheld rather than transmitted in the clear.

What Does m_f_ssl Represent?

In the ESP32-audioI2S library, m_f_ssl is a boolean member flag that is set to true when the library establishes a secure (HTTPS/SSL) connection rather than a plain HTTP one. It's already tracked internally by the library for other purposes — the fix simply reuses this existing signal to gate credential transmission.

The Full Diff

- if (auth > 0) {
+ if (auth > 0 && m_f_ssl) {
      strcat(rqh, "Authorization: Basic ");
      strcat(rqh, authorization);
      strcat(rqh, "\r\n");
  }

One line changed. One condition added. Credentials no longer travel over unencrypted connections.

Limitations to Be Aware Of

This fix prevents the leak but doesn't change the underlying authentication scheme. HTTP Basic Auth, even over TLS, still has weaknesses:

  • Credentials are sent on every request (no session tokens)
  • No protection against server-side compromise
  • No mutual authentication

For highest security, consider digest authentication or token-based schemes if your streaming server supports them. But for the vast majority of ESP32 audio projects, "only send credentials over TLS" is a practical and sufficient improvement.


Prevention & Best Practices

1. Always Tie Authentication to Transport Security

Never send credentials — regardless of encoding scheme — over unencrypted channels. This applies to:

  • HTTP Basic Auth
  • API keys in headers
  • Session tokens
  • OAuth bearer tokens

If the transport isn't encrypted, the credential isn't protected.

2. Use HTTPS Endpoints Where Possible

When connecting to audio streams or any authenticated service from an ESP32, prefer https:// URLs. The ESP32's WiFiClientSecure class supports TLS, and the audioI2S library already handles HTTPS connections — use them.

// Prefer this:
audio.connecttohost("https://stream.example.com/radio", "user", "pass");

// Not this:
audio.connecttohost("http://stream.example.com/radio", "user", "pass");

3. Avoid Hardcoding Credentials in Firmware

Store credentials in:
- NVS (Non-Volatile Storage) on the ESP32, loaded at runtime
- A configuration file on SPIFFS/LittleFS, excluded from version control
- A provisioning flow that sets credentials after deployment

This way, if firmware is extracted or shared, credentials aren't embedded in the binary.

4. Validate Connection Security Before Sending Sensitive Data

This is the pattern the fix implements — a general principle worth applying everywhere:

// Pattern: gate sensitive operations on security preconditions
if (hasCredentials && isConnectionSecure) {
    sendCredentials();
}

5. Code Review for Authentication Logic

When reviewing authentication code, always ask:
- Is the transport encrypted? (TLS/SSL check)
- Are credentials validated server-side? (not just client-side)
- What happens if the security check fails? (fail closed, not open)

Relevant Standards and References

Standard Relevance
OWASP Top 10 - A02: Cryptographic Failures Transmitting credentials without encryption
CWE-319: Cleartext Transmission of Sensitive Information Exact category for this vulnerability
CWE-522: Insufficiently Protected Credentials Credential storage and transmission weaknesses
RFC 7617 - HTTP Basic Auth Specification explicitly requiring TLS

Tools to Detect This Issue

  • Static analysis: Tools like Semgrep can be configured with rules that flag Basic Auth usage without TLS checks
  • Network analysis: Wireshark or tcpdump to verify no credentials appear in plaintext traffic
  • Firmware analysis: Binwalk to check if credentials are embedded in compiled firmware
  • Automated security scanning: AI-assisted scanners (like the one that caught this issue) can identify authentication logic that lacks transport security checks

Conclusion

This vulnerability is a textbook example of how a small oversight in authentication logic can have outsized consequences on embedded systems. The ESP32-audioI2S library correctly implemented the mechanics of HTTP Basic Auth — encoding credentials, attaching the header — but missed the critical precondition: Basic Auth is only safe when the transport is encrypted.

The fix is a single line, but the lesson is broader:

Authentication and encryption are not the same thing. You need both.

For embedded IoT developers, the stakes are higher than on traditional platforms. Credentials are hard to rotate, devices are often unmonitored, and network environments (shared Wi-Fi, guest networks, coffee shops) are frequently untrusted. Building in transport security checks from the start — and having automated tools that catch regressions — is not optional. It's essential.

If you're using the ESP32-audioI2S library in a project that authenticates against a streaming server, update to the patched version and ensure your stream URLs use https://.


This vulnerability was identified and fixed by OrbisAI Security as part of an automated security scanning pipeline. Automated security tooling caught what human code review missed — a reminder that layered security practices, including static analysis and AI-assisted scanning, are worth investing in.

Frequently Asked Questions

What is HTTP Basic Auth credential exposure?

HTTP Basic Authentication encodes credentials in Base64 (not encryption) and transmits them in the Authorization header. When sent over plain HTTP, anyone on the network can decode and read them.

How do you prevent HTTP Basic Auth credential exposure in ESP32/Arduino?

Check that the connection uses HTTPS/SSL before adding the Authorization header. Only transmit credentials over encrypted TLS connections.

What CWE is HTTP Basic Auth credential exposure?

CWE-319: Cleartext Transmission of Sensitive Information. This covers any scenario where sensitive data is sent over an unencrypted channel.

Is Base64 encoding enough to protect HTTP Basic Auth credentials?

No. Base64 is encoding, not encryption. Any attacker who captures the traffic can instantly decode Base64 credentials. TLS encryption is required for protection.

Can static analysis detect HTTP Basic Auth credential exposure?

Yes. Static analysis tools can identify when Authorization headers are constructed without verifying the connection uses HTTPS, flagging potential cleartext credential transmission.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #4

Related Articles

high

How Denial of Service via infinite loop happens in Node.js dependencies and how to fix it

A high-severity Denial of Service vulnerability in the nanoid package (CVE-2026-67213) was discovered in the project's dependency tree, where crafted input could trigger an infinite loop during random ID generation. The fix upgrades nanoid from 3.3.17 to 3.3.18 and adds an npm override to ensure all transitive dependencies use the patched version.

high

How Dependabot Missing Cooldown happens in GitHub Actions and how to fix it

A Dependabot configuration in `.github/dependabot.yml` was missing cooldown periods for both its npm and GitHub Actions package ecosystems, meaning newly published — potentially malicious or unstable — package versions could be proposed for adoption immediately after release. Adding a `cooldown` block with `default-days: 7` to each ecosystem entry creates a 7-day buffer, allowing the security community time to identify and flag compromised packages before they reach your codebase.

high

How pnpm Missing Minimum Release Age happens in Node.js workspaces and how to fix it

A missing `minimumReleaseAge` setting in `pnpm-workspace.yaml` left this Node.js workspace vulnerable to immediately installing newly published — potentially malicious — package versions. The fix adds `minimumReleaseAge: 10080` (7 days in minutes) to enforce a quarantine window before any freshly published package can be installed. This single configuration change significantly reduces the risk of supply chain attacks targeting the package publishing pipeline.

high

How Dependabot Missing Cooldown happens in GitHub Actions and how to fix it

A high-severity misconfiguration in `.github/dependabot.yml` left three `package-ecosystem` entries without a cooldown period, meaning Dependabot could immediately propose updates from newly published—potentially malicious—packages. The fix adds a `cooldown` block with `default-days: 7` to each entry, introducing a mandatory waiting period before any newly released package version is surfaced as an update candidate. For a Node.js library whose vulnerabilities ripple downstream to all consumers,

critical

How Unauthenticated Proxy Endpoints Enable DoS Amplification in FastAPI and how to fix it

Public proxy endpoints in `backend/api/proxy.py` had no rate limiting, allowing any attacker to flood the httpx connection pool with unauthenticated requests and amplify denial-of-service attacks against downstream tile and coordinate-conversion services. The fix introduces a per-IP sliding-window rate limiter using environment-configurable thresholds, closing the amplification vector without breaking legitimate usage.

high

How Dependabot Missing Cooldown happens in GitHub Actions and how to fix it

A missing `cooldown` block in `.github/dependabot.yml` meant that Dependabot could immediately propose updates to newly published npm packages — including those that may be malicious, compromised, or unstable. By adding a `cooldown` with `default-days: 7`, the project now waits one week before surfacing new package versions, giving the security community time to detect and flag bad releases before they reach production.