mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Obstruct EXTRACT() field name deparse injection.
The parser accepts any string as an EXTRACT() field name, but deparsing does not quote and escape it accordingly. To fix, quote and escape the field name during deparsing as needed. It might be a good idea to validate the field name during parsing and deparsing, too, but that is left as a future exercise. Reported-by: Ben Morris in collaboration with Claude and Anthropic Research Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com> Security: CVE-2026-15741 Backpatch-through: 14
This commit is contained in:
committed by
Noah Misch
parent
57835938fa
commit
f9729b5078
@@ -11812,7 +11812,7 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
|
||||
Assert(IsA(con, Const) &&
|
||||
con->consttype == TEXTOID &&
|
||||
!con->constisnull);
|
||||
appendStringInfoString(buf, TextDatumGetCString(con->constvalue));
|
||||
appendStringInfoString(buf, quote_identifier(TextDatumGetCString(con->constvalue)));
|
||||
}
|
||||
appendStringInfoString(buf, " FROM ");
|
||||
get_rule_expr((Node *) lsecond(expr->args), context, false);
|
||||
@@ -11832,6 +11832,7 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
|
||||
Assert(IsA(con, Const) &&
|
||||
con->consttype == TEXTOID &&
|
||||
!con->constisnull);
|
||||
/* NB: safe because no allowed words need quoted/escaped */
|
||||
appendStringInfo(buf, " %s",
|
||||
TextDatumGetCString(con->constvalue));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user