openwallet-foundation / askar

Secure storage designed for Hyperledger Aries agents.
Apache License 2.0
63 stars 51 forks source link

SQLite expiry compare is not correct. #260

Closed dkulic closed 5 months ago

dkulic commented 6 months ago

In SQLite comparison of expiry date is done using query

(expiry IS NULL OR expiry > DATETIME('now'))

but SQLite considers text strings for date and time comparisons by character order, not by their actual date/time value., so the check is not working correctly and Askar returns the items stored even after expired.

The fix is easy, expiry should be first converted to DATETIME, in above query something like:

(expiry IS NULL OR DATETIME(expiry) > DATETIME('now'))