Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ IzzyOnDroid) and used as the GitHub Release notes.

## [Unreleased]

### Security

- Someone who only knows your duress PIN can no longer set the clock forward to make the next real unlock delete old notes from your trash early: the decoy vault now has its own trash timer. Turning the duress PIN off or setting a new one now checks that the old decoy database is really deleted and fails otherwise. Changing PINs inside the decoy vault is refused after the same pause as in the real vault. The vault no longer opens when the screen switches off and on while the PIN is still being checked.

### Added

- Encly for Windows, macOS and Linux (MSI, DMG, DEB and a Flatpak bundle): the same vault, notes and security as on the phone, with list and note side by side, note tabs, several windows, keyboard shortcuts and a menu bar, export to PDF and print, and the PIN's device key in the system's secret store ([#85](https://github.com/pasichDev/Encly/issues/85), [#106](https://github.com/pasichDev/Encly/issues/106)).
Expand Down
37 changes: 34 additions & 3 deletions PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@ ignore these requests, so use one you trust.
This data is stored in Encly's private app storage. Android cloud backup and device-to-device
transfer are disabled for it, so it is not copied to Google Drive or another phone.

## Duress PIN and decoy vault (optional)

In **Settings → Security** you can set a **duress PIN**: a second PIN, typed on the lock screen
like any other. Instead of your real vault it opens a **decoy vault**, a separate vault that
starts empty and works like the real one, so you can show someone "the app" without showing your
notes. It erases nothing, and your real vault stays closed and unchanged while the decoy is open.
It is not meant to hide your real vault from someone who examines the phone's storage.

What it keeps on your device, in the same private app storage as everything else:

- **The decoy vault's notes, tags and tasks**, in a second database file of its own
(`vault_b.db`), encrypted with SQLCipher under its own random key. The file is created the
first time the duress PIN is used and kept between locks until you remove it.
- **Two entries of security metadata:** the encrypted key envelope that the duress PIN opens, and
the decoy vault's key sealed under your real vault's key (so changing the duress PIN keeps the
decoy notes). Both exist, with the same size, whether or not you set a duress PIN, so the
metadata does not show whether you did. The duress PIN itself is never stored.
- **The same app settings** (theme, sort order, editor font, auto-lock delay, keyboard privacy)
are used in both vaults.

Inside the decoy vault, what belongs to your real vault does not work: changing the PINs,
fingerprint unlock, the recovery phrase, encrypted backups and "Erase all data". Fingerprint
unlock and the recovery phrase on the lock screen always open the real vault. An encrypted backup
never contains decoy notes. Markdown export and notes import do work there, on the decoy vault's
own notes, and the files they make are yours to keep or delete (see the export sections below).

Turning the duress PIN off (Settings → Security, after your PIN and a confirmation) deletes the
decoy vault and its notes. The wipe PIN and **Erase all data** delete the decoy vault together with
the real one. See [SECURITY.md → Duress PIN](SECURITY.md#duress-pin) for the technical details and
what it does not hide.

## Permissions

| Permission | Why |
Expand Down Expand Up @@ -127,9 +158,9 @@ in a readable format first.
## Deleting your data

Uninstalling Encly, or clearing its storage in Android settings, permanently deletes all of
it, and so does **Settings → Security → Erase all data**. There is no copy anywhere else, apart
from encrypted backups you exported yourself. If you did not keep a recovery seed, a forgotten
PIN also means the data cannot be recovered.
it, and so does **Settings → Security → Erase all data** (the decoy vault too, if you have one).
There is no copy anywhere else, apart from encrypted backups you exported yourself. If you did not
keep a recovery seed, a forgotten PIN also means the data cannot be recovered.

## Children

Expand Down
67 changes: 56 additions & 11 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,14 @@ meant for "open the app and show me", not against a forensic examination.
on every miss is locked out, escalating as above, even right after the duress PIN opened the
decoy vault. Without that, someone who was given the duress PIN could guess at the real
PIN 4 times, type the duress PIN to reset the lockout, and repeat without limit. The cost is a
tell after that many misses (a lockout sooner than the screen suggests), and a store-level
one: after misses, a duress unlock leaves `pin.strikes` in the state file with no lockout
failures, which a real PIN unlock never does, so anyone who can read the app's private files
can then see that a duress PIN exists and that the last unlock was a non-PIN one. A duress
unlock with no misses before it leaves the same entries as a real PIN unlock.
store-level tell: after misses, a duress unlock leaves `pin.strikes` in the state file with no
matching lockout failures, which a real PIN unlock never does, so anyone who can read the app's
private files can see that a duress PIN exists. The entry stays until the real PIN is typed
again (or a new PIN is set, or the wipe PIN erases the vault): later misses, fingerprint
unlocks and recovery-phrase unlocks do not clear it, so someone who unlocks mostly with a
fingerprint can carry it for weeks. On screen, from the 10th strike on every miss is locked out
(as above). A duress unlock with no misses before it leaves the same entries as a real PIN
unlock.
- **Rules.** 6 to 12 digits, different from the PIN and from the wipe PIN (checked by opening their
slots with it); a wipe PIN equal to the duress PIN is refused, and so is changing the PIN to
the duress PIN, since either would silently orphan the decoy notes. A reset of the PIN's
Expand All @@ -305,20 +308,31 @@ meant for "open the app and show me", not against a forensic examination.
- **Inside the decoy vault.** Notes, tags, tasks, trash, search, sorting and appearance work as
usual. Settings shows the same entries as in the real vault, and everything that belongs
to the real vault is refused by the security layer and fails like a storage error would, with
the usual generic message: changing the PIN, the wipe and duress PINs, fingerprint unlock, the
recovery phrase, encrypted backups (export and import) and "Erase all data". A PIN re-check
there accepts the duress PIN only, so the decoy vault itself cannot be used to test guesses
of the real PIN; on the lock screen the strikes above bound them. Fingerprint unlock and the recovery phrase on the lock screen always open the real
the usual generic message: changing the PIN, the wipe and duress PINs, the recovery phrase,
encrypted backups (export and import) and "Erase all data" (fingerprint unlock is the
exception, see the next item). A PIN re-check there accepts the duress PIN only, so the decoy
vault itself cannot be used to test guesses of the real PIN; on the lock screen the strikes
above bound them. A refused PIN change there runs the same KDF step as the real vault's own
work (one PBKDF2 and Keystore run over the PIN typed), so the refusal does not come back
faster. Fingerprint unlock and the recovery phrase on the lock screen always open the real
vault, and nothing in the decoy vault offers a way to switch: to change vaults, lock and type
the other PIN. App settings (theme, sorting, font, auto-lock, keyboard privacy) are shared.
- **Fingerprint in the decoy vault (a known tell).** Settings there shows fingerprint unlock as
it is set in the app, but the decoy vault cannot use it: the PIN re-check dialogs (allowing
screenshots, Markdown export, confirming a weaker setting, erase) have no fingerprint key,
although the real vault's offer one, and turning the fingerprint switch on or off fails at once
with an error of its own and no system fingerprint prompt. Someone who knows the app can notice.
- **Session isolation.** Only one database is open at a time. Every repository is bound to the
opening it was created in (a lease revoked before Room closes), so nothing created in one
vault reads or writes the other. Opening the other vault starts a new epoch, so the note that
was open when the app re-locked is reopened only in the vault it belongs to.
- **Failures never fall back.** A decoy database that does not open fails the unlock; it is
neither deleted nor replaced by the real vault. Turning the duress PIN off (after the PIN and a
confirmation) forgets the decoy key first and then deletes `vault_b.db`; a kill in between
leaves a file nothing can open, which the next duress PIN set replaces.
leaves a file nothing can open, which the next duress PIN set replaces. The delete is
checked: the database file and its `-wal`, `-shm`, `-journal` and lock files must be gone, or
turning the duress PIN off reports a failure, and setting a new duress PIN (which also starts
by deleting an old `vault_b.db`) fails instead of leaving a PIN that opens a stale file.
- **Wipe PIN.** The erase also replaces both decoy entries with random bytes and deletes
`vault_b.db` with the real database: the empty vault has no decoy vault either.
- **Limits.** The decoy vault does not hide that the real one exists from a forensic look: the
Expand All @@ -328,7 +342,38 @@ meant for "open the app and show me", not against a forensic examination.
"Important limitations") finds the duress PIN as well.
- **Downgrade.** Older builds ignore both entries and the second database and keep opening the
real vault. A PIN changed in an older build gets a new salt, which silently turns the duress
PIN off; the decoy notes come back once it is set again in this version.
PIN off; the decoy notes come back once it is set again in this version. An erase in 2.1.x
(the wipe PIN or "Erase all data") predates the decoy vault and does not know `vault_b.db`, so
the file can stay on disk (encrypted) after it.

#### What an observer can and cannot tell

From the review of 2026-11-21 (someone made to see the app, or reading an image of the phone's
storage).

Checked and safe:

- The state file has the same entries and sizes with or without a duress PIN, through setting it,
changing it, turning it off, a PIN change and the erase.
- Every PIN attempt costs the same (one KDF run, all three slots tried), whichever PIN it is.
- No data of the real vault is reachable from the decoy: it opens only its own database, every
operation of the real vault is refused there, and its PIN re-check accepts the duress PIN only.
- Nothing outside the two databases records which vault was used: the shared settings hold
appearance and privacy choices, the what's-new version and the trash purge times (the decoy
vault's own one is written only after it purged), and there are no notifications, widgets,
shortcuts or attachments on disk.

Still visible:

- Fingerprint in the decoy vault (above).
- `pin.strikes` in the state file after a duress unlock that followed misses (above).
- Encrypted backups exported earlier are named `encly-backup-*` in shared storage and can show in
the file picker's recent list, which the decoy vault's Import screen opens. The decoy vault
itself says "never exported".
- "What's new" and the trash notice after an update are shown to whichever vault is unlocked
first, so a duress unlock can use them up before the real vault shows them.
- The second database file, its size and timestamps (see Limits).
- The downgrade note above, for someone who goes back to 2.1.x.

### Biometric slot

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.AlarmManager
import android.app.Application
import android.content.Context
import android.os.Looper
import android.os.SystemClock
import androidx.test.core.app.ApplicationProvider
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -84,6 +85,45 @@ class AlarmMainThreadTimerTest {
assertNull(shadowOf(alarms).nextScheduledAlarm)
}

@Test
fun theAlarmsOfTheFifteenAndThirtyMinuteDelaysAreSetForThoseDelays() {
listOf(15L, 30L).forEach { minutes ->
val delay = TimeUnit.MINUTES.toMillis(minutes)
val before = SystemClock.elapsedRealtime()

val cancel = timer.schedule(delay) { runs++ }

val alarm = shadowOf(alarms).nextScheduledAlarm!!
assertTrue(
"$minutes min: ${alarm.triggerAtTime - before}",
alarm.triggerAtTime - before in delay..delay + 1_000,
)
assertEquals(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarm.type)
assertTrue(alarm.isAllowWhileIdle)
cancel()
assertNull(shadowOf(alarms).nextScheduledAlarm)
}
}

@Test
fun aLongDelayHandlerThatNeverRanLeavesTheAlarmToRunTheAction() {
timer.schedule(TimeUnit.MINUTES.toMillis(30)) { runs++ }
val id = alarmId()

pass(TimeUnit.MINUTES.toMillis(29)) // a frozen process: in real life nothing would run here

assertEquals("not yet", 0, runs)
assertTrue(AlarmMainThreadTimer.fire(id))
assertEquals(1, runs)
}

@Test
fun anAlarmThatOutlivedItsProcessFindsNoActionAndDoesNothing() {
// The process died with the alarm pending: the new process has no action under that id.
assertFalse(AlarmMainThreadTimer.fire(Int.MAX_VALUE - 7))
assertEquals(0, runs)
}

private fun alarmId(): Int =
shadowOf(shadowOf(alarms).nextScheduledAlarm!!.operation).savedIntent.getIntExtra(AwayLockReceiver.EXTRA_ID, -1)
}
Loading
Loading