Closed Bug 1657178 (CVE-2021-23967) Opened 6 years ago Closed 5 years ago

Bypassing App Lock [Firefox Lockwise - iOS]

Categories

(Lockwise Graveyard :: Security, defect)

Other
iOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: 1808ar.arvind, Assigned: st3fan)

References

Details

(Keywords: csectype-priv-escalation, reporter-external, sec-high, Whiteboard: [reporter-external] [client-bounty-form] [verif?])

Attachments

(1 file, 1 obsolete file)

Platform affected:

Description:

Lockwise app "App Lock" feature allows the user to lock the app using Face / Touch ID. The "Auto Lock" timeout feature will lock the app automatically after user specified duration.

I set the timeout to "1 minute", so the app will lock automatically after 1 minute of inactivity (after I close the app). When I reopen the app after 1 minute or later, it prompts me to unlock before accessing the app.

But this feature does not work as intended. After 1 minute or LATER, if I change the device time to 1 hour backward and reopen the app, it allows me to access the app completely without unlocking (the app fails to prompt me to unlock).

NOTE: This issue also occurs if I change the device date to 1 day backward.

Impact:

An attacker can access all the passwords stored in the Lockwise app without unlocking the app lock by just reversing device date or time.

Steps to reproduce:

NOTE: PoC video attached.

  1. Install the Lockwise app.
  2. Open the app and login your account.
  3. Go to Settings, set "Auto Lock" to "1 Minute" (you can also select any other duration).
  4. Close the app.
  5. After 1 minute or LATER, change the device time to 1 hour backward (or) change the device date to 1 day backward.
  6. Now reopen the app (Now the app will not prompt to unlock and you can access the app completely).

Fix

The "Auto lock" feature works in this logic:

Lockwise app stores the app closed time (timestamp) when user closes the app. When user reopens the app, it compares current device time with the app closed time. If the difference is greater than (>) user specified duration (For example: 1 minute), then it will prompt the user to unlock.

If attacker changes the device time to app closed time / any earlier time and reopens the app, it fails to prompt to unlock because the current device time will be same / earlier than the app closed time.

The problem is using [NSDate().timeIntervalSince1970] (current time). Use [ProcessInfo.systemUptime] (device up time) for time interval calculation.

-> [NSDate().timeIntervalSince1970] - Returns current time in milliseconds.

-> [ProcessInfo.systemUptime] - Returns the amount of time the system has been awake since the last time it was restarted.

https://developer.apple.com/documentation/foundation/processinfo/1414553-systemuptime

Group: mobile-core-security
OS: Unspecified → iOS
Product: Firefox → Lockwise
Hardware: Unspecified → Other

NI to Garvan to have a look

Flags: needinfo?(gkeeley)
Flags: needinfo?(gkeeley) → needinfo?(kgalway)
Type: task → defect

Guessing sec-high because this defeats the whole point of having a password lockout, but on the other hand it does presuppose a local attacker who has access to your unlocked device which hopefully indicates a certain level of trust; sec-moderate might also be appropriate.

Flags: needinfo?(kgalway)

Unclear who owns this app now with recent reorg - removing needinfo from my account and requesting info/next steps from Jeremy Evans and David Bolter.

Flags: needinfo?(jeevans)
Flags: needinfo?(dbolter)

Wennie is LW back in your arena?

Flags: needinfo?(dbolter) → needinfo?(wleung)

Re-routing NI to Stefan for awareness. Not sure we can/should get to this before EOL?

Flags: needinfo?(wleung) → needinfo?(sarentz)

Hi everyone. Quick update that we have set a plan in motion to ship a fix for this bug.

Arvind, thank you very much for this report and also for the suggested remediation. I will be working with engineering to implement a fix. I know some time has passed, but I would like to ask for some patience while we let this bug go through the process. This is still a sec-high report and I will also work with dveditz to officially confirm the bounty.

I'll keep people updated here. To set expectations - we have two build issues to work through before we can land this fix, and I expect that to happen in the coming week or two.

Flags: needinfo?(sarentz)
Alias: CVE-2021-23967

The steps to reproduce also work in the iOS simulator.

  • Run the app through Xcode in any Simulator
  • Set auto lock to 1 minute
  • Move to the Simulator home screen
  • Wait a minute
  • In your Mac's Date & Time settings, turn back time 🎶
  • Bring Lockwise to the foreground

Expected is that Lockwise is still locked. In reality it unlocks since it's internal time-to-lock logic is flawed.

Fix incoming.

Attached patch patch (obsolete) — — Splinter Review
Assignee: nobody → sarentz

Attached the patch, which is being reviewed in a private fork on GitHub.

Hi Stefan, thanks for fixing this issue. Sorry for the delay, just now I found that there is a issue in the fix.

  • ProcessInfo.processInfo.systemUptime - it will return milliseconds since boot, but not counting the time device spent in the sleep. This clock would pause when the device screen is turned OFF and resume only after the device screen is turned ON back.

Assume user sets the timeout to "12 hours", then the app will lock after 12 hours only if the user kept the device screen ON for 12 hours totally (after closing the app).

Issue scenario:

  1. Set "Auto Lock" to 1 minute.
  2. Close the app.
  3. Turn OFF the device screen.
  4. After 1 minute or later, turn ON the device screen.
  5. Now reopen the app, it won't prompt you to unlock.

To fix this issue, app should get device up time including the sleep time.

func uptime() -> time_t {
    var boottime: timeval
    let mib = [CTL_KERN, KERN_BOOTTIME]
    var size = MemoryLayout.size(ofValue: boottime)
    var now: time_t
    var uptime: time_t = -1

    time(&now)

    if sysctl(mib, 2, &boottime, &size, nil, 0) != -1 && boottime.tv_sec != 0 {
        uptime = now - boottime.tv_sec
    }

    return uptime
}

Reference: https://github.com/TelegramMessenger/Telegram-iOS/blob/master/submodules/MonotonicTime/Sources/DeviceUptime.m

Interesting! I need to give this a try because that is not what I experienced in my testing. The Telegram code is good for reference but it also depends on the system clock to get final uptime value. So I am not sure how much I like that. This patch was to avoid using the clock.

I think what I will go with is actually clock_gettime(CLOCK_MONOTONIC_RAW, ...) - this is a simpler API. I'll verify with a test app that this is working correctly.

(Did find out that kern.boottime is adjusted when the system clock changes - but I think I simply prefer something simpler that does not touch the clock at all.)

Attached patch patch2 — — Splinter Review
Attachment #9200741 - Attachment is obsolete: true
Flags: needinfo?(jeevans)

We have a 1.8.0-RC build on TestFlight. If this passes QA then we will ship it soon.

Verified fix on v1.8.0 (4249).

This version is now rolling out over the coming days.

From an engineering perspective this is RESOLVED/FIXED.

Dan, can I ask you for next steps regarding this bug?

Flags: needinfo?(dveditz)

This bug appears to have been filed using the client bug bounty form yet did not have the bounty request flag. I don't see that it got removed so that's a bit disturbing. Adding the flag manually so the bounty committee can find and evaluate this one.

Dan, can I ask you for next steps regarding this bug?

We should wait until we're comfortable turning updates to 100% (or close to it) before publishing the advisory, but that can be tracked in some PM-ish place and isn't usually done in the bug.

Group: firefox-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Flags: needinfo?(dveditz) → sec-bounty?
Resolution: --- → FIXED
Group: mobile-core-security → core-security-release
Flags: sec-bounty? → sec-bounty+

Thanks so much for the reward.

Arvind, we published the advisory at https://github.com/mozilla-lockwise/lockwise-ios/security/advisories/GHSA-xpfj-mwf5-rmpv

Would you like to be mentioned in it? It is easy to include a GitHub account or let me know what name you want me to put in there.

Flags: needinfo?(1808ar.arvind)

Hi Stefan,

Yes, please mention me in the advisory.

My Github account: https://github.com/ar-arvind

Thanks so much.

Flags: needinfo?(1808ar.arvind)

Hi Stefan,

My Github account is still not included in the advisory (https://github.com/mozilla-lockwise/lockwise-ios/security/advisories/GHSA-xpfj-mwf5-rmpv), can you please check it?

And also my name is not included in the Hall of Fame page (https://www.mozilla.org/en-US/security/bug-bounty/hall-of-fame/), am I eligible?

Thanks.

Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: