Skip to content
Access control Write-up Intermediate

I Reported the Bugs. Nobody Fixed Them. So I Fixed Them Myself | CVE-2026-82452 and CVE-2026-82453

The rust-iot-platform project left 162 of 163 API endpoints without any authentication check, and stored and returned user passwords in plaintext. An attacker could reach those endpoints without logging in and read every user's password from the API responses.

Harsh Raj Singhania Follow

Published on medium.com

Cybersecurity

Harsh Raj Singhania, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

Context

rust-iot-platform is an open source Rust project for IoT work. The researcher had previously reported two vulnerabilities in it, CVE-2026-82452 and CVE-2026-82453, and both were published. VulnCheck rated the authentication bypass Critical, 9.8. The first issue was systemic missing authentication across 162 out of 163 API endpoints. The second was passwords stored and returned in plaintext.

This article is about what happened when the researcher went back to check whether either had been fixed, and what he found while writing the patches himself.

Setup

The work was done against the current main branch of the repository, reading the same files the researcher had been in before. No special accounts or tooling are described beyond pulling the branch, reading the source, and later running the project's tests locally. The repository had 313 stars at the time.

Finding it

Weeks after the CVEs were published, the researcher pulled main and re-read the relevant files. Neither vulnerability had been fixed.

The authentication problem was unchanged. Every route handler except POST /userinfo still had no AuthToken parameter in its signature. In Rocket, a request guard that is not named as a parameter never runs, and no middleware layer picks up the slack. The same 162 endpoints that had no auth when the first post was written had no auth on the second check.

The password problem was also unchanged. user_biz.rs still inserted passwords as raw strings, and the login query still did a direct string equality match:

SQL
WHERE username = ? AND password = ?

That comparison only works if the database column holds plaintext. Any authenticated user calling the user listing or user-by-ID endpoints still received the passwords back in the response body, unmasked.

The earlier post described all of this in detail and linked the VulnCheck advisories with the CVE numbers. There was no indication anyone had looked at the repository's security tab. So the researcher opened an issue, made a fork, and wrote the fixes.

Exploitation

Step 1: Confirm the missing auth guard

Reading the route handlers on main showed that only POST /userinfo declared an AuthToken parameter. The other 162 endpoints declared none, so the guard never executed for them. No request is needed to demonstrate this: the absence is visible in the handler signatures.

Step 2: Confirm plaintext password storage and disclosure

The insert path in user_biz.rs wrote the password value straight into the row:

SQL
sqlx::query!(    "INSERT INTO users (username, password, ...) VALUES (?, ?, ...)",    user.username,    user.password,       ...)

Because the stored value is plaintext, the login query's WHERE username = ? AND password = ? succeeds on a direct string match. The same plaintext value was serialised back to clients: the user listing and user-by-ID endpoints returned the password field in the response body, unmasked, to any authenticated user.

Step 3: Inspect the AuthToken guard

The original guard only checked that the Authorization header existed:

Rust
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {        } else if let Some(value) = request.headers().get_one("Authorization") {        Outcome::Success(AuthToken(value.to_string()))            }

Whatever string the header contained, an expired token, a token signed with someone else's key, or the word "hello", was marked as a success. The value was stored in AuthToken and then essentially ignored.

Step 4: Read the JWT setup in main.rs

While reading main.rs to understand how JWTs were signed, the researcher found the signing secret:

Rust
let secret = env::var("JWT_SECRET").unwrap_or_else(|_| "a_secret_test123456".to_string());

If JWT_SECRET is not set in the environment, the application falls back to "a_secret_test123456", a string that sits in the repository's public source code. Tokens are signed with that secret, so anyone who knows it can forge valid tokens for any user, including admin accounts, on any deployment that ran without the environment variable explicitly set.

Root cause

Three separate mistakes, all in the application code.

  1. Guard not wired in. Rocket request guards only run when named as handler parameters. The AuthToken guard was implemented but omitted from 162 handler signatures, and there was no middleware to compensate. The guard that did exist was also ineffective: it accepted any Authorization header value without parsing or verifying the JWT, so even where it ran it granted access on the presence of a string alone.
  2. Plaintext passwords. Passwords were inserted as raw strings and compared with direct string equality, which only works against plaintext. The User struct serialised the password field, so the stored value was returned in API responses.
  3. Hardcoded fallback secret. The JWT signing key defaulted to a public constant when the environment variable was absent, silently, with no startup check. Any deployment that never set JWT_SECRET signed tokens with a key that is public on GitHub.

Impact

On the authentication bypass, the researcher's earlier assessment stands: 162 of 163 endpoints had no effective authentication. VulnCheck rated it Critical, 9.8.

On the password issue, any authenticated user could retrieve other users' passwords in plaintext from the user listing or user-by-ID endpoints, and the database stored them in cleartext.

On the hardcoded secret, anyone who knows the public fallback string can forge valid tokens for any user, including admin accounts, on any deployment that ever ran without JWT_SECRET explicitly set. The researcher escalated this as a separate vulnerability to the CNA, VulnCheck, for its own CVE assignment.

Fix

The researcher opened an issue and a pull request on the upstream repository. The PR is on branch fix/cve-2026-82452-82453 and contains five commits:

  1. Fix CVE-2026-82452 and CVE-2026-82453, Argon2id hashing and JWT verification
  2. Harden authentication and remove hardcoded JWT secret
  3. Harden authentication and remove hardcoded JWT secret (follow-up)
  4. Require a strong external JWT secret
  5. Document JWT secret configuration in README

CVE-2026-82453: Argon2id with gradual migration

A fix that only hashed new passwords would leave existing plaintext rows vulnerable, and wiping the table would break logins. The chosen approach migrates each row on first successful login.

Creating and updating users now hashes first:

Rust
// After (fixed):let hash = hash_password(&user.password)?;sqlx::query!(    "INSERT INTO users (username, password, ...) VALUES (?, ?, ...)",    user.username,    hash,            // $argon2id$... string    ...)

hash_password() uses Argon2id, the current recommended standard for password hashing, and generates a unique salt internally, so two users with the same password produce completely different hash strings.

Login now looks the user up by username only, then decides how to verify:

Rust
// After (fixed):// 1. Look up by username onlylet user = find_user_by_username(&username).await?;// 2. Verify the submitted password against the stored valueif is_plaintext_password(&user.password) {    // Legacy row: compare directly, then migrate    if user.password != submitted_password {        return Err(AuthError::InvalidCredentials);    }    // Migrate: hash and update the stored value    let hash = hash_password(&submitted_password)?;    update_password_hash(user.id, &hash).await?;} else {    // Normal row: verify hash    verify_password(&submitted_password, &user.password)?;}

The migration check is whether the stored value starts with $argon2id$. If it does not, the row is legacy plaintext: compare directly, and on a match immediately replace the stored value with a hash before returning success. After one successful login each user's password is in Argon2id format, with no credential resets needed.

To stop the field leaking in responses, the struct skips it during serialisation:

Rust
#[derive(Serialize, Deserialize)]pub struct User {    pub id: u64,    pub username: String,    #[serde(skip_serializing)]       pub password: String,    ...}

The hash stays in the database and never reaches the API response, including from the user listing and user-by-ID endpoints.

CVE-2026-82452: verifying the JWT in the guard

The guard now requires the header, accepts both Bearer <token> and a raw token, and decodes and verifies the JWT before accepting the request:

Rust
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {    let header_value = match request.headers().get_one("Authorization") {        Some(v) => v,        None => return Outcome::Error((            Status::Unauthorized,            Json(ErrorResponse { message: "Authorization header missing".to_string() })        )),    };
Rust
    // Support both "Bearer <token>" and raw token    let token = header_value        .strip_prefix("Bearer ")        .unwrap_or(header_value);    // Actually decode and verify the JWT    match parse_token(token) {        Ok(claims) => Outcome::Success(AuthToken(claims.sub)),        Err(_) => Outcome::Error((            Status::Unauthorized,            Json(ErrorResponse { message: "Invalid or expired token".to_string() })        )),    }}

parse_token validates the signature against the JWT signing key, checks expiry, and returns the claims. A token signed with a different key, an expired token, or arbitrary text in the header all return 401.

The guard still has to be named in each handler's parameter list to run, so the structural problem of 162 handlers without it remains. The PR adds it to the user-management routes as a starting point; covering all 162 would require the maintainers to go through every controller file.

Hardcoded JWT secret

The application now validates JWT_SECRET at startup, requires at least 32 bytes, and refuses to start without it:

Rust
// In main.rs startup:let jwt_secret = env::var("JWT_SECRET")    .expect("JWT_SECRET environment variable must be set");
Rust
if jwt_secret.len() < 32 {    panic!("JWT_SECRET must be at least 32 bytes for security");}

If the variable is not set, the process exits immediately instead of running with a known-compromised signing key.

Tests and local verification

The PR includes unit tests for hash and verify, a test confirming that password is excluded from serialised user objects, and README documentation for JWT_SECRET setup and the Bearer token format. Local testing:

Bash
export JWT_SECRET="$(openssl rand -base64 48)"cargo test -p api

After deploying, any tokens issued under the old hardcoded secret should be treated as compromised. The Argon2id migration handles existing passwords automatically on first login.

Where things stand

The PR is open, the issue is open, and there has been no response from the maintainers. The researcher notes that the repository has 313 stars and no dedicated security team, and that unmaintained open source projects do not always respond to PRs, even ones that fix published CVEs. Until it is merged, the practical path for anyone running rust-iot-platform is to apply the changes manually: the authentication fix is in user_router.rs and the AuthToken implementation in main.rs, the password hashing is in user_biz.rs and db_model.rs, and the JWT secret validation is in main.rs startup.

Variants to test

  • Guards that exist but are never named. In any Rocket (or similar framework with parameter-driven guards) codebase, grep handler signatures for the guard type. A guard implementation with no call sites in the router is a positive result: the endpoints are unauthenticated.
  • Guards that only check presence. Look for guards that call headers().get_one(...) and return success without parsing the value. A positive result is that any string, including hello, is accepted as a token.
  • Plaintext password columns. Check the insert and login queries. A WHERE username = ? AND password = ? equality match, or an insert of the raw password field, indicates plaintext storage. A positive result is retrieving the password field from a listing or by-ID endpoint.
  • Serialised secret fields. Look for structs that derive Serialize and include credential fields without #[serde(skip_serializing)]. A positive result is a response body containing a password or hash.
  • Hardcoded fallback secrets. Search for env::var(...).unwrap_or_else(...) and similar patterns around signing keys. A positive result is a public constant used as a JWT signing key; forge a token for an admin account and confirm it is accepted.
  • Startup validation gaps. Check whether the application refuses to start when the signing secret is missing or short. A positive result is a server that boots with a default or weak key.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 22 min read.

What happened, in plain words

Imagine a block of flats where the front door has a lock, but the lock was never actually fitted to the door. The keyhole is there, the key turns, and the door opens for anybody who walks up. That is roughly the situation in a piece of open source software called rust-iot-platform, and this is the story of what happened after the person who spotted the problem told everyone about it, waited, and then fixed it himself.

rust-iot-platform is a program for working with IoT devices. IoT stands for "Internet of Things": everyday objects such as sensors, thermostats, smart plugs and industrial equipment that talk to a computer over a network. The program is written in Rust, a programming language, and it is open source, which means the full source code is published on the internet for anyone to read, use and improve. It handles incoming requests through a web framework and stores its data in a database.

A few months before this article, the researcher had found two security bugs in this project and reported them. Both were given CVE numbers. A CVE is a public catalogue entry for a known security flaw: it gives the bug a permanent identifier so that everyone, from software vendors to system administrators, can refer to the same thing. The two entries were CVE-2026-82452 and CVE-2026-82453. A company called VulnCheck, which publishes security advisories, rated the first one Critical, with a score of 9.8. That score comes from a system called CVSS, which rates how severe a vulnerability is on a scale where 10 is the worst possible.

The first bug was that 162 out of the project's 163 API endpoints had no working authentication. An API is the set of doors and windows through which other programs talk to a server: each endpoint is one specific address, such as "list all users" or "fetch user number 7". Authentication is the process of proving who you are, like showing a passport at a border. If an endpoint has no authentication, anyone who can reach it can use it, with no account and no password.

The second bug was that passwords were stored and sent back in plaintext. Plaintext means exactly what it sounds like: the actual readable characters, not scrambled in any way. If you store a password as plaintext, anyone who can read the database, or who can ask the program to list users, sees the password as clearly as you see this sentence.

Both bugs were published. Weeks passed. Then the researcher went back to look, and neither had been fixed. So he opened an issue (a public note on the project's code hosting page), made a fork (his own personal copy of the code), wrote the fixes himself, and submitted them as a pull request, usually shortened to PR: a formal proposal to the project's owners saying "please take these changes and add them to the official version".

While writing those fixes he found a third bug, a hardcoded secret used to sign login tokens. He escalated that one separately to the CNA for its own CVE assignment. This article walks through all of it, in the order it happened, in language that assumes no security background at all.

From the original on medium.com

The starting point

The work was done against the current main branch of the repository. A branch is a line of development inside a code repository; main is normally the official, current version that everyone builds from. The researcher pulled that branch, meaning he downloaded the latest copy to his own machine, and read the same files he had been reading before. The article does not describe any special accounts or tools beyond that: reading the source code, and later running the project's own tests on his computer.

At the time, the repository had 313 stars. A star is the bookmark or "like" button on a code hosting site such as GitHub; it is a rough measure of how many people are paying attention to a project.

Finding it

The authentication problem was still there

When the researcher re-read the code, the authentication problem had not changed at all. Every route handler except one, POST /userinfo, still had no AuthToken parameter in its signature.

A route handler is the piece of code that runs when a particular address is requested. A signature is the line at the top of a function that lists what it takes in and what it gives back, a bit like the ingredients list on a recipe. AuthToken is the name of a check in the Rocket framework called a request guard: a small piece of code whose job is to inspect an incoming request and decide whether it is allowed through. In Rocket, a guard only runs if it is named in the handler's parameter list. If it is not named, it is never called, no matter how well written it is. There is no separate layer of middleware, meaning no general checkpoint that every request passes through, to catch what the guard misses.

So the same 162 endpoints that had no authentication when the first article was written still had none on the second check. The one exception was POST /userinfo.

The password problem was still there

user_biz.rs is one of the project's source files; the .rs ending marks a Rust file, and biz is short for business logic, the part that decides what the program does. That file still inserted passwords as raw strings, meaning the exact characters the user typed, with no scrambling. The login query still did a direct string equality match:

SQL
WHERE username = ? AND password = ?

This is a line of SQL, the language used to talk to databases. WHERE means "only pick rows that match this condition". The two question marks are placeholders that get filled in with the username and password the person typed. AND means both conditions must be true. So the line says: find the row where the stored username equals the one supplied and the stored password equals the one supplied.

That comparison only works if the database column holds plaintext. If the stored password were scrambled, the typed password would never equal it as a string, and login would fail. The fact that the query is written this way is itself evidence that the column holds readable passwords.

Worse, the same plaintext value was being sent back out. The user listing endpoint (which returns all users) and the user-by-ID endpoint (which returns one user) both included the password field in the response body, unmasked, to any authenticated user. A response body is the actual content a server sends back, as opposed to the status line and headers around it. Unmasked means it was not hidden, starred out or removed.

Nobody had looked

The earlier article had described all of this in detail and linked the VulnCheck advisories with the CVE numbers. There was no sign that anyone had even opened the repository's security tab, the section of a code hosting site where vulnerability reports and advisories are collected. So the researcher opened an issue, made a fork, and wrote the fixes.

How the bugs could be used

Step 1: Confirm the missing auth guard

Reading the route handlers on main showed that only POST /userinfo declared an AuthToken parameter. The other 162 declared none, so the guard never ran for them. No request is needed to demonstrate this: the absence is visible in the handler signatures, the same way you can see a door has no lock without trying to open it.

Step 2: Confirm plaintext password storage and disclosure

The insert path in user_biz.rs wrote the password value straight into the row:

SQL
sqlx::query!(    "INSERT INTO users (username, password, ...) VALUES (?, ?, ...)",    user.username,    user.password,       ...)

Line by line: sqlx::query! is a macro, a piece of code that writes more code for you, from the SQLx library, used to send a database query. The string after it is the SQL statement. INSERT INTO users means "add a new row to the table called users". The column list in brackets says which fields are being filled in: username, password, and others represented by .... VALUES (?, ?, ...) supplies the values for those columns, again with placeholders. The lines below pass the actual values: user.username is the username from the incoming data, and user.password is the password exactly as submitted. Because user.password goes in raw, the database stores readable text.

Because the stored value is plaintext, the login query's WHERE username = ? AND password = ? succeeds on a direct string match. The same plaintext value was then serialised back to clients. Serialising means turning an in-memory object into a format that can be sent over the network, usually JSON, a text format of curly brackets, names and values. The user listing and user-by-ID endpoints returned the password field in the response body, unmasked, to any authenticated user. In other words, anyone with any account at all could read everyone else's passwords.

Step 3: Inspect the AuthToken guard

The original guard only checked that the Authorization header existed:

Rust
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {        } else if let Some(value) = request.headers().get_one("Authorization") {        Outcome::Success(AuthToken(value.to_string()))            }

Line by line: async fn from_request declares a function called from_request that runs asynchronously, meaning it can pause while waiting for slow work without blocking everything else. It takes a request, which represents the incoming HTTP request, and returns an Outcome, Rocket's way of saying "allowed" or "rejected". The else if let Some(value) = request.headers().get_one("Authorization") line asks: does this request have a header called Authorization? A header is a small labelled piece of information attached to a request, like the address block on an envelope. Authorization is the conventional header for carrying proof of identity. If the header is present, Outcome::Success(AuthToken(value.to_string())) marks the request as successful and stores the header's text in an AuthToken value.

That is all it did. Whatever string the header contained, an expired token, a token signed with someone else's key, or the word "hello", was marked as a success. The value was stored in AuthToken and then essentially ignored. A token, in this context, is a string a server hands you after login so you can prove who you are on later requests without resending your password; a JWT, or JSON Web Token, is a particular kind of token that carries signed claims, meaning statements about you such as your user ID, together with a cryptographic signature that lets the server check the token was really issued by it and has not been altered.

Step 4: Read the JWT setup in main.rs

While reading main.rs, the file where the program starts up, to understand how JWTs were signed, the researcher found the signing secret:

Rust
let secret = env::var("JWT_SECRET").unwrap_or_else(|_| "a_secret_test123456".to_string());

Line by line: let secret = creates a variable called secret and gives it a value. env::var("JWT_SECRET") asks the operating system for an environment variable named JWT_SECRET. An environment variable is a named setting kept outside the program, usually configured on the server, so that secrets do not have to live in the code. .unwrap_or_else(|_| "a_secret_test123456".to_string()) says: if that lookup fails, use this fallback instead. The fallback is the literal string "a_secret_test123456", and .to_string() turns it into an owned text value the program can use.

If JWT_SECRET is not set in the environment, the application falls back to "a_secret_test123456", a string that sits in the repository's public source code. Tokens are signed with that secret. A signature is like a wax seal: it proves the document came from the holder of the seal and was not changed afterwards. Anyone who knows the secret can forge valid tokens for any user, including admin accounts, on any deployment that ran without the environment variable explicitly set. Forging means creating a token the server will accept as genuine, without ever logging in.

Why it happened

Three separate mistakes, all in the application code.

  1. The guard was not wired in. Rocket request guards only run when named as handler parameters. The AuthToken guard was implemented but omitted from 162 handler signatures, and there was no middleware to compensate. The guard that did exist was also ineffective: it accepted any Authorization header value without parsing or verifying the JWT, so even where it ran it granted access on the presence of a string alone.
  2. Passwords were plaintext. Passwords were inserted as raw strings and compared with direct string equality, which only works against plaintext. The User struct, the code's description of what a user record contains, serialised the password field, so the stored value was returned in API responses.
  3. The signing secret had a hardcoded fallback. The JWT signing key defaulted to a public constant when the environment variable was absent, silently, with no startup check. Any deployment that never set JWT_SECRET signed tokens with a key that is public on GitHub.

What the impact was

On the authentication bypass, the researcher's earlier assessment stands: 162 of 163 endpoints had no effective authentication. VulnCheck rated it Critical, 9.8.

On the password issue, any authenticated user could retrieve other users' passwords in plaintext from the user listing or user-by-ID endpoints, and the database stored them in cleartext.

On the hardcoded secret, anyone who knows the public fallback string can forge valid tokens for any user, including admin accounts, on any deployment that ever ran without JWT_SECRET explicitly set. The researcher escalated this as a separate vulnerability to the CNA, VulnCheck, for its own CVE assignment. A CNA, or CVE Numbering Authority, is an organisation authorised to assign CVE identifiers.

The fix

The researcher opened an issue and a pull request on the upstream repository, meaning the original project rather than his fork. The PR is on branch fix/cve-2026-82452-82453 and contains five commits. A commit is a saved, labelled change in a repository's history.

  1. Fix CVE-2026-82452 and CVE-2026-82453, Argon2id hashing and JWT verification
  2. Harden authentication and remove hardcoded JWT secret
  3. Harden authentication and remove hardcoded JWT secret (follow-up)
  4. Require a strong external JWT secret
  5. Document JWT secret configuration in README

CVE-2026-82453: Argon2id with gradual migration

A fix that only hashed new passwords would leave existing plaintext rows vulnerable, and wiping the table would break logins. Hashing means running a password through a one-way mathematical function so that the result cannot practically be turned back into the original. The chosen approach migrates each row on first successful login: the old plaintext is replaced with a hash the first time that user signs in.

Creating and updating users now hashes first:

Rust
// After (fixed):let hash = hash_password(&user.password)?;sqlx::query!(    "INSERT INTO users (username, password, ...) VALUES (?, ?, ...)",    user.username,    hash,            // $argon2id$... string    ...)

Line by line: let hash = hash_password(&user.password)?; takes the submitted password, passes it to a function called hash_password, and stores the result in a variable called hash. The ? at the end means: if hashing fails, stop here and pass the error up. The SQL is the same insert as before, but the value supplied for the password column is now hash instead of user.password. The comment // $argon2id$... string notes that the stored value will begin with $argon2id$, which is how Argon2id hashes are labelled.

hash_password() uses Argon2id, the current recommended standard for password hashing, and generates a unique salt internally, so two users with the same password produce completely different hash strings. A salt is random data mixed in before hashing, so that identical passwords do not produce identical hashes; without it, an attacker could hash a list of common passwords once and compare the results against the whole database.

Login now looks the user up by username only, then decides how to verify:

Rust
// After (fixed):// 1. Look up by username onlylet user = find_user_by_username(&username).await?;// 2. Verify the submitted password against the stored valueif is_plaintext_password(&user.password) {    // Legacy row: compare directly, then migrate    if user.password != submitted_password {        return Err(AuthError::InvalidCredentials);    }    // Migrate: hash and update the stored value    let hash = hash_password(&submitted_password)?;    update_password_hash(user.id, &hash).await?;} else {    // Normal row: verify hash    verify_password(&submitted_password, &user.password)?;}

Line by line: let user = find_user_by_username(&username).await?; fetches the user record using only the username, and .await means wait for the database to answer. if is_plaintext_password(&user.password) asks whether the stored value looks like an old, unscrambled password. If it does, the code compares the stored value with what was submitted: if user.password != submitted_password means "if they are not equal", and in that case return Err(AuthError::InvalidCredentials); stops and returns an error saying the credentials are wrong. If they are equal, let hash = hash_password(&submitted_password)?; hashes the submitted password and update_password_hash(user.id, &hash).await?; writes the hash back to that user's row. The else branch handles rows that are already hashed: verify_password(&submitted_password, &user.password)?; checks the submitted password against the stored hash.

The migration check is whether the stored value starts with $argon2id$. If it does not, the row is legacy plaintext: compare directly, and on a match immediately replace the stored value with a hash before returning success. After one successful login each user's password is in Argon2id format, with no credential resets needed.

To stop the field leaking in responses, the struct skips it during serialisation:

Rust
#[derive(Serialize, Deserialize)]pub struct User {    pub id: u64,    pub username: String,    #[serde(skip_serializing)]       pub password: String,    ...}

Line by line: #[derive(Serialize, Deserialize)] is an attribute, a note attached to the code, that tells the compiler to generate the code needed to convert this struct to and from formats such as JSON. pub struct User { begins the definition of a user record. pub id: u64, is a numeric identifier, and pub username: String, is the username. #[serde(skip_serializing)] is the key line: it tells the serialisation library, Serde, to leave this field out when converting the struct to JSON. pub password: String, is the password field itself, which stays in the database but never appears in an outgoing response.

The hash stays in the database and never reaches the API response, including from the user listing and user-by-ID endpoints.

CVE-2026-82452: verifying the JWT in the guard

The guard now requires the header, accepts both Bearer <token> and a raw token, and decodes and verifies the JWT before accepting the request:

Rust
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {    let header_value = match request.headers().get_one("Authorization") {        Some(v) => v,        None => return Outcome::Error((            Status::Unauthorized,            Json(ErrorResponse { message: "Authorization header missing".to_string() })        )),    };

Line by line: the function signature is the same as before. let header_value = match request.headers().get_one("Authorization") { looks for the Authorization header and starts a match, a Rust construct that handles each possible outcome separately. Some(v) => v, means: if the header is there, take its value and call it v. None => return Outcome::Error(( means: if it is missing, return an error. Status::Unauthorized, is HTTP status 401, the standard code for "you are not authorised". Json(ErrorResponse { message: "Authorization header missing".to_string() }) builds a JSON error body with that message. The closing }; ends the match.

Rust
    // Support both "Bearer <token>" and raw token    let token = header_value        .strip_prefix("Bearer ")        .unwrap_or(header_value);    // Actually decode and verify the JWT    match parse_token(token) {        Ok(claims) => Outcome::Success(AuthToken(claims.sub)),        Err(_) => Outcome::Error((            Status::Unauthorized,            Json(ErrorResponse { message: "Invalid or expired token".to_string() })        )),    }}

Line by line: let token = header_value.strip_prefix("Bearer ").unwrap_or(header_value); removes the word Bearer and the space after it if it is present, and otherwise keeps the value as it is. Bearer is the conventional prefix for this kind of header, and accepting both forms makes the guard tolerant of clients that send either. match parse_token(token) { calls a function that decodes and verifies the token and branches on the result. Ok(claims) => Outcome::Success(AuthToken(claims.sub)), means: if verification succeeded, allow the request and store the user identifier from the token's claims, where sub is the standard claim name for the subject, the user the token is about. Err(_) => Outcome::Error(( means: if verification failed for any reason, return an error. Status::Unauthorized, is again 401, and the JSON body says "Invalid or expired token".

parse_token validates the signature against the JWT signing key, checks expiry, and returns the claims. A token signed with a different key, an expired token, or arbitrary text in the header all return 401.

The guard still has to be named in each handler's parameter list to run, so the structural problem of 162 handlers without it remains. The PR adds it to the user-management routes as a starting point; covering all 162 would require the maintainers to go through every controller file.

The hardcoded JWT secret

The application now validates JWT_SECRET at startup, requires at least 32 bytes, and refuses to start without it:

Rust
// In main.rs startup:let jwt_secret = env::var("JWT_SECRET")    .expect("JWT_SECRET environment variable must be set");

Line by line: let jwt_secret = env::var("JWT_SECRET") reads the environment variable. .expect("JWT_SECRET environment variable must be set"); means: if the lookup fails, stop the program immediately with that message. There is no fallback any more.

Rust
if jwt_secret.len() < 32 {    panic!("JWT_SECRET must be at least 32 bytes for security");}

Line by line: if jwt_secret.len() < 32 { checks whether the secret is shorter than 32 bytes, where a byte is a unit of data roughly equal to one character of ordinary text. panic!("JWT_SECRET must be at least 32 bytes for security"); stops the program with that message if it is. A short secret is easier to guess, so the length check forces a reasonably strong one.

If the variable is not set, the process exits immediately instead of running with a known-compromised signing key.

Tests and local verification

The PR includes unit tests for hash and verify, a test confirming that password is excluded from serialised user objects, and README documentation for JWT_SECRET setup and the Bearer token format. A unit test is a small automated check that one piece of code behaves as expected. Local testing:

Bash
export JWT_SECRET="$(openssl rand -base64 48)"cargo test -p api

Line by line: export JWT_SECRET="$(openssl rand -base64 48)" sets the environment variable for the current terminal session. openssl rand -base64 48 asks the OpenSSL tool to generate 48 random bytes and encode them as base64, a text encoding that turns binary data into ordinary characters. cargo test -p api runs the tests for the api package using Cargo, Rust's build and package tool.

After deploying, any tokens issued under the old hardcoded secret should be treated as compromised. The Argon2id migration handles existing passwords automatically on first login.

Where things stand

The PR is open, the issue is open, and there has been no response from the maintainers. The researcher notes that the repository has 313 stars and no dedicated security team, and that unmaintained open source projects do not always respond to PRs, even ones that fix published CVEs. Until it is merged, the practical path for anyone running rust-iot-platform is to apply the changes manually: the authentication fix is in user_router.rs and the AuthToken implementation in main.rs, the password hashing is in user_biz.rs and db_model.rs, and the JWT secret validation is in main.rs startup.

Patterns worth testing elsewhere

These are the general lessons, written so that someone auditing another project can look for the same shapes.

  • Guards that exist but are never named. In any Rocket (or similar framework with parameter-driven guards) codebase, grep handler signatures for the guard type. Grep means search text for a pattern. A guard implementation with no call sites in the router is a positive result: the endpoints are unauthenticated.
  • Guards that only check presence. Look for guards that call headers().get_one(...) and return success without parsing the value. A positive result is that any string, including hello, is accepted as a token.
  • Plaintext password columns. Check the insert and login queries. A WHERE username = ? AND password = ? equality match, or an insert of the raw password field, indicates plaintext storage. A positive result is retrieving the password field from a listing or by-ID endpoint.
  • Serialised secret fields. Look for structs that derive Serialize and include credential fields without #[serde(skip_serializing)]. A positive result is a response body containing a password or hash.
  • Hardcoded fallback secrets. Search for env::var(...).unwrap_or_else(...) and similar patterns around signing keys. A positive result is a public constant used as a JWT signing key; forge a token for an admin account and confirm it is accepted.
  • Startup validation gaps. Check whether the application refuses to start when the signing secret is missing or short. A positive result is a server that boots with a default or weak key.

Glossary

  • API: the set of addresses and rules through which one program talks to another over a network.
  • Endpoint: one specific address in an API, such as "list users" or "fetch user 7".
  • Authentication: proving who you are, usually with a username and password or a token.
  • Authorization header: the conventional HTTP header that carries proof of identity with a request.
  • Header: a small labelled piece of information attached to a request or response.
  • Response body: the actual content a server sends back, as opposed to its status and headers.
  • Token: a string issued after login that proves identity on later requests without resending the password.
  • JWT (JSON Web Token): a token containing signed claims about a user, which the server can verify.
  • Signature: cryptographic proof that data came from the holder of a secret key and was not altered.
  • Claims: the statements inside a JWT, such as which user it is about.
  • Secret / signing key: the private value used to create and check signatures; anyone who knows it can forge tokens.
  • Hardcoded: written directly into the source code rather than configured from outside.
  • Environment variable: a named setting kept outside the program, usually on the server.
  • Fallback: a default value used when the intended one is missing.
  • Plaintext / cleartext: readable text, not scrambled in any way.
  • Hashing: a one-way transformation of data, such as a password, that cannot practically be reversed.
  • Salt: random data mixed into a password before hashing so identical passwords produce different hashes.
  • Argon2id: a modern, recommended password hashing algorithm.
  • Migration: converting existing stored data, here plaintext passwords, to the new format.
  • Serialisation: turning an in-memory object into a format such as JSON that can be sent over a network.
  • JSON: a text format of curly brackets, names and values used to exchange data.
  • Struct: a code definition describing what fields a record contains.
  • Request guard: in Rocket, a check that inspects an incoming request and decides whether it is allowed.
  • Middleware: a general layer that every request passes through.
  • Route handler: the code that runs when a particular address is requested.
  • Signature (of a function): the line declaring a function's name, inputs and outputs.
  • SQL: the language used to query and change databases.
  • Database column: one named field within a table of records.
  • CVE: a public catalogue entry giving a known security flaw a permanent identifier.
  • CNA (CVE Numbering Authority): an organisation authorised to assign CVE identifiers.
  • CVSS: a scoring system for the severity of a vulnerability, from 0 to 10.
  • Critical: the highest severity band in CVSS.
  • Vulnerability: a weakness in software that can be used to cause harm.
  • Authentication bypass: getting access without proving identity, as intended.
  • Fork: a personal copy of someone else's repository.
  • Pull request (PR): a proposal to add your changes to a project.
  • Issue: a public note on a code hosting site reporting a problem or request.
  • Commit: a saved, labelled change in a repository's history.
  • Branch: a line of development inside a repository; main is the official current version.
  • Repository: the storage location for a project's code and its history.
  • Star: a bookmark or "like" on a code hosting site, a rough measure of attention.
  • Unit test: a small automated check that one piece of code behaves as expected.
  • Rust: a programming language.
  • Rocket: a web framework for Rust that handles incoming requests.
  • SQLx: a Rust library for talking to databases.
  • Serde: a Rust library for converting data to and from formats such as JSON.
  • Cargo: Rust's build and package tool.
  • Base64: a text encoding that turns binary data into ordinary characters.
  • OpenSSL: a widely used tool and library for cryptography.
  • IoT (Internet of Things): everyday and industrial devices that communicate over a network.
  • Open source: software whose source code is published for anyone to read, use and improve.
  • Maintainer: a person responsible for a project's code and changes.
  • Grep: to search text for a pattern.

More by Harsh Raj Singhania

View all

9 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.