by marcobambini on 5/22/25, 1:25 PM with 57 comments
by jmull on 5/22/25, 2:12 PM
BTW, it looks like the js engine is "QuickJS" [0]. (I'm not familiar with it myself.)
I like it because sqlite by itself lacks a host language. (e.g., Oracle's plsql, Postgreses pgplsql, Sqlserver's t-sql, etc). That is: code that runs on compute that is local to your storage.
That's a nice flexible design -- you can choose whatever language you want. But quite typically you have to bring one, and there are various complications to that.
It's quite powerful, BTW, to have the app-level code that acts on the app data live with the data. You can present cohesive app-level abstraction to the client (some examples people will hopefully recognize: applyResetCode(theCode) or authenticateSessionToken(), or whatever), which can be refined/changed without affecting clients. (Of course you still have to full power and flexibility of SQL and relational data for the parts of your app that need it.)
by bob1029 on 5/22/25, 4:11 PM
You can build really powerful domain-specific SQL scripting engines using this interface. The functions bound to SQL can be anything. They do not have to be deterministic or free of side effects.
Microsoft has a really good provider & docs around how to use this with .NET/C#:
https://learn.microsoft.com/en-us/dotnet/standard/data/sqlit...
by sgarland on 5/22/25, 8:53 PM
WITH ordered_nums AS (
SELECT num, ROW_NUMBER() OVER (ORDER BY num) as rn,
COUNT(*) OVER() as total
FROM nums
)
SELECT AVG(num) as median
FROM ordered_nums
WHERE rn IN (
(total + 1) / 2,
(total + 2) / 2
);
[0]: https://www.sqlite.org/lang_corefunc.htmlby Wheaties466 on 5/23/25, 12:10 PM
by abirch on 5/22/25, 2:03 PM
by gwbas1c on 5/22/25, 1:46 PM
by hbcondo714 on 5/22/25, 4:52 PM
Darn, ANN would be awesome to have on the edge.
by 3cats-in-a-coat on 5/23/25, 12:10 PM
by neuroelectron on 5/22/25, 10:42 PM
CVE-2024-0418 (and similar recent ones like CVE-2024-32593, CVE-2024-32592): These often relate to how QuickJS handles certain object properties or internal structures, potentially leading to crashes (Denial of Service) or, in more severe cases, memory corruption issues like heap-based buffer overflows or use-after-free vulnerabilities. These types of memory corruption can sometimes be escalated to arbitrary code execution, though it's not always straightforward.
CVE-2021-40517: A use-after-free vulnerability when handling Array.prototype.concat with a specially crafted proxy object. This could lead to a crash or potentially code execution.
CVE-2020-13951: An issue in JSON.parse that could lead to a stack overflow (Denial of Service) with deeply nested JSON structures.
It's not V8 or SpiderMonkey, which have dedicated, large security teams and decades of hardening due to their use in browsers handling actively malicious web content. QuickJS is primarily the work of one (albeit brilliant) developer.This means that while it's well-written, the sheer volume of security research and fuzzing applied to browser engines is likely greater.
The responsibility for security falls on multiple layers:
Fabrice Bellard for QuickJS itself.
The sqlite-js developers (
@marcobambini
marcobambini Marco Bambini
@Gioee
Gioee Gioele Cantoni)
for how they embed, configure, and update QuickJS, and what APIs they expose.
The end-user/DBA for controlling who can define JavaScript UDFs and for keeping sqlite-js (and thus its QuickJS version) updated.
by gcv on 5/22/25, 4:21 PM
by cal85 on 5/22/25, 2:59 PM
by gorm on 5/22/25, 9:26 PM
SELECT js_create_scalar('function_name', 'function_code');
Really cool project! Thanks for sharing.
by 9dev on 5/22/25, 2:33 PM
by rileytg on 5/22/25, 1:49 PM
by datadrivenangel on 5/22/25, 3:12 PM
by rcarmo on 5/23/25, 12:06 PM
by timz on 5/23/25, 5:22 AM
by rasz on 5/23/25, 8:50 AM
by orliesaurus on 5/22/25, 10:09 PM
by pdyc on 5/22/25, 4:57 PM
by porridgeraisin on 5/22/25, 2:35 PM
Reminds me of awk, Nice.
by mcflubbins on 5/22/25, 4:14 PM