CVE-2018-8023: Timing attack on the JWT implementation of Apache Mesos

A flaw in the JWT implementation of Apache Mesos resulted in a timing attack vulnerability.

Affected Versions

Apache Mesos 1.4.0 to 1.6.0 are affected. The unsupported Apache Mesos pre-1.4.0 releases may be also affected.

Description

Apache Mesos can be configured to require authentication to call the Executor HTTP API. This is done by running the Mesos Agent with the --authenticate_http_executors flag. By default, this authentication mechanism utilizes JSON Web Token (JWT).

The JWT is eventually validated at 3rdparty/libprocess/src/jwt.cpp with the function JWT::parse(const string& token, const string& secret).

The following snippet of code contains the vulnerability:

248  const bool valid = hmac.get() == signature.get();
249
250  if (!valid) {
251    return JWTError(
252        "Token signature does not match",
253        JWTError::Type::INVALID_TOKEN);
254  }
255
256  return JWT(header.get(), payload.get(), signature.get());

The vulnerability lies in the comparison of the generated HMAC value against the provided signature. As the == operator in C++ is not constant-time, an attacker is able to abuse the timing difference of when this function returns to reveal the correct HMAC value. The blog post "A Lesson In Timing Attacks (or, Don't use MessageDigest.isEquals)" from Coda Hale has more details about exploiting such vulnerabilities.

By exploiting this vulnerability, an attacker can learn the expected HMAC value and bypass the authentication checks of the Executor HTTP API.

Mitigation

Apache Mesos user's should be upgraded to a patched version. The following is the official recommendation from the Apache Mesos team.

pre-1.4.x users should upgrade to at least 1.4.2
1.4.x users should upgrade to 1.4.2
1.5.x users should upgrade to 1.5.2
1.6.0 users should upgrade to 1.6.1
1.7.0-dev users should obtain Mesos 1.7.0

Credits

This issue was discovered by Ayrx.

Timeline

If you have any feedback or notice any errors in the post, I'd love to hear from you. You can find various ways of contacting me at the about me page!