From 99957e18c40aea0e175b4adedc96af2e5b68ab15 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Tue, 19 May 2026 05:36:36 +0100 Subject: [PATCH] fix(spoof): validate currentPatch against date regex currentPatch returned the raw system= value unchanged. A malformed value such as system=tomorrow flowed into the lexicographic comparison `date > current`, where any well-formed YYYY-MM-DD from the bulletin sorts before lowercase letters, so the poller permanently judged its date "not newer" and never applied an update. Validate the read value against the date pattern; on mismatch, log a warning and treat as passive. --- .../org/matrix/TEESimulator/config/BulletinPoller.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/matrix/TEESimulator/config/BulletinPoller.kt b/app/src/main/java/org/matrix/TEESimulator/config/BulletinPoller.kt index 390418b..69ce02b 100644 --- a/app/src/main/java/org/matrix/TEESimulator/config/BulletinPoller.kt +++ b/app/src/main/java/org/matrix/TEESimulator/config/BulletinPoller.kt @@ -24,6 +24,7 @@ object BulletinPoller { private val BOOTSTRAP_INTERVALS = longArrayOf(5_000, 30_000, 120_000, 600_000, 1_800_000) private val DATE_REGEX = Regex("(\\d{4}-\\d{2}-\\d{2})") + private val PATCH_DATE_PATTERN = Regex("^\\d{4}-\\d{2}-\\d{2}$") private lateinit var handler: Handler @Volatile private var bootstrapStep = 0 @@ -119,7 +120,7 @@ object BulletinPoller { private fun currentPatch(): String? { val f = File(PATCH_FILE) if (!f.exists()) return null - return try { + val raw = try { f.readLines() .firstOrNull { it.startsWith("system=") } ?.substringAfter("system=") @@ -128,6 +129,12 @@ object BulletinPoller { } catch (_: Exception) { null } + if (raw == null) return null + if (PATCH_DATE_PATTERN.matches(raw)) return raw + SystemLogger.warning( + "BulletinPoller: ignoring malformed system='$raw' in $PATCH_FILE" + ) + return null } private fun appendHistory(result: FetchResult) {