Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Login iOS SDK Authentication Token Has No Signature #2442

Open
5 tasks done
paul-livefront opened this issue Jun 18, 2024 · 4 comments
Open
5 tasks done

Facebook Login iOS SDK Authentication Token Has No Signature #2442

paul-livefront opened this issue Jun 18, 2024 · 4 comments

Comments

@paul-livefront
Copy link

paul-livefront commented Jun 18, 2024

Checklist before submitting a bug report

Xcode version

15.3

Facebook iOS SDK version

17.0.2

Dependency Manager

SPM

SDK Framework

Login

Goals

We're attempting to migrate to the Limited Login flow in the latest versions of the iOS SDK. We get back an AuthenticationToken (JWT), but we're unable to validate it because the signature portion of the JWT is always missing/empty.

Expected results

The JWT contained in AuthenticationToken.current?.tokenString after login should have a propertly formatted header, payload, and signature.

Actual results

The JWT contains a header and payload, but the signature is empty.

Steps to reproduce

Login with limited tracking configured.
After the successful login attempt. AuthenticationToken.current?.tokenString has an incomplete JWT value.

Code samples & details

guard let configuration = LoginConfiguration(
    permissions: [.publicProfile, .email],
    tracking: .limited
) else {
    return
}

logIn(viewController: viewController, configuration: configuration) { result in
    switch result {
    case .success:
        // We should now have a valid AuthenticationToken.current?.tokenString.
    default:
        // handle errors
    }
}
@811414114
Copy link

811414114 commented Jun 18, 2024 via email

@briangithex
Copy link

By default, any attempt to print or otherwise display the tokenstring is truncated by XCode. Often, this results in receiving 1.5 to 2.5 of the 3 segments during testing/development.

@ricsantos
Copy link

Any update on this? Is is bad practice to just read the Profile object and send those properties straight to the server to create/login the user?

if let profile = Profile.current {
    print("FB Profile: \(profile.description)")
    print("FB Profile userID: \(profile.userID)")
    print("FB Profile first: \(profile.firstName)")
    print("FB Profile last: \(profile.lastName)")
    print("FB Profile email: \(profile.email)")
}

@briangithex
Copy link

briangithex commented Jul 10, 2024

Any update on this?

Did you verify it wasn't the truncation issue I mention above? If AuthenticationToken.current?.tokenString is missing the signature but otherwise looks like a valid token, that probably means you're reading it in a way that causes truncation (XCode does this in places you wouldn't expect).

Is is bad practice to just read the Profile object and send those properties straight to the server to create/login the user?

Yes, this is very bad practice. With this approach, it would be possible to maliciously pose as another user. Further, a compromised user account's login will not properly "expire" after it is recovered, since this data is replayable due to having neither a timestamp nor a signature (nor a nonce). The client-side profile information should be treated the same as any other user-supplied information: Useful in places where you'd trust the user or where the attacker is attacking themselves (e.g., "Welcome back, [First] [Last]" messages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants