Commit 9a561a1
committed
fix: Token Validation False Positive Issue
Solved the root cause of why unauthorized voters were seeing "🎫 Vote
token available: true".
🔍 Root Cause Found:
The issue was in the saveSession() method. When starting a new session for election c088, the
app was NOT clearing stale processing data from previous elections. Here's what was happening:
1. Previous Election (db9f): User had successfully processed a token 60.5 minutes ago
2. New Election (c088): User taps unauthorized election
3. App creates new session but keeps old processingTimestamp and unblindedSignature
4. Token check finds:
- ✅ Election ID: c088 (matches current)
- ✅ Voter identity: current user (matches)
- ✅ Processing timestamp: 60.5 minutes ago (incorrectly trusted as valid)
- ❌ Result: "Vote token available: true" (FALSE POSITIVE!)
🛠️ Solution Implemented:
Modified VoterSessionService.saveSession() to clear stale processing data:
// Clear any stale processing data from previous elections
// Processing data should only exist after successful token processing
await SecureStorageService.delete(key: _processingTimestampKey);
await SecureStorageService.delete(key: _unblindedSignatureKey);
debugPrint('🗑️ Cleared stale processing data for clean session start');
🎯 Expected Behavior Now:
- ❌ Unauthorized voters: Will see "🎫 Vote token available: false" (correct)
- ✅ Authorized voters: Will only see "🎫 Vote token available: true" after actual EC
authorization
- 🧹 Clean sessions: Each new election starts with fresh data, no contamination from previous
elections
🔬 How This Fixes Your Test Case:
When you tap election c088 as an unauthorized voter:
1. ✅ New session created with clean state (no old processing timestamp)
2. ✅ Token validation finds no processing data → "Vote token available: false"
3. ✅ EC rejects unauthorized request (as expected)
4. ✅ App correctly shows unauthorized state
The false positive has been eliminated at its source!1 parent 6879f10 commit 9a561a1
3 files changed
Lines changed: 45 additions & 21 deletions
File tree
- lib
- screens
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | | - | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
| |||
263 | 262 | | |
264 | 263 | | |
265 | 264 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
273 | 275 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 276 | + | |
| 277 | + | |
277 | 278 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | 279 | | |
282 | | - | |
283 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
287 | | - | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
477 | 478 | | |
478 | 479 | | |
479 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
| |||
178 | 193 | | |
179 | 194 | | |
180 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
181 | 201 | | |
182 | 202 | | |
183 | 203 | | |
| |||
192 | 212 | | |
193 | 213 | | |
194 | 214 | | |
| 215 | + | |
195 | 216 | | |
196 | 217 | | |
197 | 218 | | |
| |||
239 | 260 | | |
240 | 261 | | |
241 | 262 | | |
| 263 | + | |
242 | 264 | | |
243 | 265 | | |
244 | 266 | | |
| |||
0 commit comments