• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 28860310413

07 Jul 2026 10:44AM UTC coverage: 83.048% (+0.06%) from 82.988%
28860310413

push

github

web-flow
fix(auth): harden RSA JWK verification against malformed keys (#1079)

Two defects in the RS256 getClaims verification path:
- JWTAlgorithm force-unwrapped JWK.rsaPublishKey, which is nil for a
  malformed key, crashing the process on attacker/network-controlled
  JWKS. Guard it and fall back to server verification.
- The DER length encoder filtered out ALL zero bytes instead of only
  leading zeros, corrupting the length for content of size 256/512/etc.
  Drop only leading zeros of the big-endian length.

5 of 6 new or added lines in 2 files covered. (83.33%)

7804 of 9397 relevant lines covered (83.05%)

37.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/Sources/Auth/Internal/JWTAlgorithm.swift
1
//
2
//  JWTVerifier.swift
3
//  Supabase
4
//
5
//  Created by Claude on 06/10/25.
6
//
7

8
import Foundation
9

10
enum JWTAlgorithm: String {
11
  case rs256 = "RS256"
12

13
  func verify(
14
    jwt: DecodedJWT,
15
    jwk: JWK
16
  ) -> Bool {
1✔
17
    let message = "\(jwt.raw.header).\(jwt.raw.payload)".data(using: .utf8)!
1✔
18
    switch self {
1✔
19
    case .rs256:
1✔
20
      #if canImport(Security)
21
        guard let publicKey = jwk.rsaPublishKey else { return false }
1✔
22
        return SecKeyVerifySignature(
×
NEW
23
          publicKey,
×
24
          .rsaSignatureMessagePKCS1v15SHA256,
×
25
          message as CFData,
×
26
          jwt.signature as CFData,
×
27
          nil
×
28
        )
×
29
      #else
30
        return false
31
      #endif
32
    }
1✔
33
  }
1✔
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc