Skip to content

Login request crash #505

Closed
Closed

Description

@zhengyipei

Describe the bug

  • (nullable NSDictionary<NSString *,NSString *> *)
    additionalTokenRefreshParametersForAuthSession:(GTMAuthSession *)authSession {
    return [GIDEMMSupport updatedEMMParametersWithParameters:
    authSession.authState.lastTokenResponse.additionalParameters];
    }

[GIDEMMSupport updatedEMMParametersWithParameters:
authSession.authState.lastTokenResponse.additionalParameters] , There are cases where the value returned by this method does not meet the required type

Activity

  1. added
    bugSomething isn't working
    triageIssues that need to be triaged
    on Feb 25, 2025
  2. removed
    triageIssues that need to be triaged
    on Mar 4, 2025
  3. brnnmrls commented on Mar 4, 2025

    @brnnmrls
    Member

    Hi! Looking for more context. Would you happen to know what the type(s) of the value you're getting is? Do you have any guesses on what cases specifically may return a different type?

  4. aforkalyuk commented on Mar 6, 2025

    @aforkalyuk
    private func authorizeRequest(withArguments args: AuthorizationArguments) {
        serialAuthArgsQueue.sync {
          authorizationArgs.append(args)
        }
        let additionalRefreshParameters = delegate?.additionalTokenRefreshParameters?(
          forAuthSession: self
        )
    
    @objc optional func additionalTokenRefreshParameters(
        forAuthSession authSession: AuthSession
      ) -> [String: String]?
    

    additionalTokenRefreshParameters must return [String: String]?, but in

    [GIDEMMSupport updatedEMMParametersWithParameters: authSession.authState.lastTokenResponse.additionalParameters]

    authSession.authState.lastTokenResponse.additionalParameters =

    {
    "refresh_token_expires_in" = 604799;
    }

  5. onewOne commented on Jul 10, 2025

    @onewOne

    Unreviewed apps with scope for login will have this issue.

    App review doesn't crash.

    My guess is that the scope authorization for unaudited apps has an expiration time, but this time is not officially handled as a string type.

  6. Aloisius commented on Oct 20, 2025

    @Aloisius

    The fix #559 by @brnnmrls will still crash if emmSupport is disabled, because the dictionary passed in that is returned in if emmSupport is null can have the "refresh_token_expires_in" = long_value in it:

    + (NSDictionary<NSString *,NSString *> *)parametersWithParameters:(NSDictionary *)parameters
                                                           emmSupport:(nullable NSString *)emmSupport
                                               isPasscodeInfoRequired:(BOOL)isPasscodeInfoRequired {
      if (!emmSupport) {
        return parameters;
      }
      ...
    

    Changing this to return [GIDEMMSupport dictionaryWithStringValuesFromDictionary:parameters] instead fixes it.

  7. AkshatG6 commented on Jan 15, 2026

    @AkshatG6
    Contributor

    Hi, this issue is fixed in Google Sign-In iOS SDK version 9.1.0.

  8. onewOne commented on Jun 4, 2026

    @onewOne

    Hi, this issue is fixed in Google Sign-In iOS SDK version 9.1.0.

    Title: GIDEMMSupport can still return non-string additional token refresh parameters from lastTokenResponse.additionalParameters

    Environment

    • GoogleSignIn: 9.1.0
    • AppAuth: 2.0.0
    • GTMAppAuth: 5.0.0
    • Platform: iOS

    Problem

    GIDEMMSupport appears to have added filtering via dictionaryWithStringValuesFromDictionary: to ensure EMM parameters are returned as NSDictionary<NSString *, NSString *>.

    However, this does not fully cover the case where no emm_support value exists.

    Current flow:

    - (nullable NSDictionary<NSString *,NSString *> *)
    additionalTokenRefreshParametersForAuthSession:(GTMAuthSession *)authSession {
      return [GIDEMMSupport updatedEMMParametersWithParameters:
              authSession.authState.lastTokenResponse.additionalParameters];
    }
    Then:
    
    + (NSDictionary<NSString *,NSString *> *)parametersWithParameters:(NSDictionary *)parameters
                                                           emmSupport:(nullable NSString *)emmSupport
                                               isPasscodeInfoRequired:(BOOL)isPasscodeInfoRequired {
      if (!emmSupport) {
        return parameters;
      }
    
      NSMutableDictionary *allParameters = [(parameters ?: @{}) mutableCopy];
      ...
      return [GIDEMMSupport dictionaryWithStringValuesFromDictionary:allParameters];
    }
    When emmSupport is nil, the method returns parameters directly. But authSession.authState.lastTokenResponse.additionalParameters comes from OIDTokenResponse.additionalParameters, whose type is not guaranteed to be NSDictionary<NSString *, NSString *>; it may contain non-string JSON values such as dictionaries, arrays, booleans, numbers, or null-like values.
    
    As a result, additionalTokenRefreshParametersForAuthSession: can still return a dictionary containing non-string values, despite its declared return type being:
    
    NSDictionary<NSString *, NSString *> *
    Expected Behavior
    updatedEMMParametersWithParameters: / parametersWithParameters:emmSupport:isPasscodeInfoRequired: should always return a string-only dictionary, including the early-return path where emmSupport is nil.
    
    Suggested Fix
    Change:
    
    if (!emmSupport) {
      return parameters;
    }
    to:
    
    if (!emmSupport) {
      return [GIDEMMSupport dictionaryWithStringValuesFromDictionary:(parameters ?: @{})];
    }
    This makes the behavior consistent with the later return path and prevents non-string values from being returned through the GTMAuthSessionDelegate additional token refresh parameters API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions