Skip to content

Commit 73d8f06

Browse files
goffrieConvex, Inc.
authored andcommitted
Limit cron job args to 1MiB (#42387)
This seems very unlikely to happen because cron jobs have constant args that are hardcoded in the push bundle, but we want a limit to protect the database. GitOrigin-RevId: 2d7e796d3cd1444d00952dd600702a2a616a3183
1 parent 0d4cc74 commit 73d8f06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/model/src/cron_jobs/types.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ use value::{
3838
ConvexObject,
3939
ConvexValue,
4040
ResolvedDocumentId,
41+
Size,
42+
MAX_USER_SIZE,
4143
};
4244

4345
#[derive(thiserror::Error, Debug, Clone)]
@@ -484,9 +486,17 @@ impl TryFrom<JsonValue> for CronSpec {
484486

485487
let udf_path: UdfPath = j.name.parse()?;
486488
let udf_path_canonicalized = udf_path.canonicalize();
489+
let udf_args = ConvexArray::try_from(j.args)?;
490+
// CronSpec is stored in the database, so enforce document size limits
491+
anyhow::ensure!(
492+
udf_args.size() < MAX_USER_SIZE,
493+
"Cron job args too large ({} > maximum size {})",
494+
udf_args.size(),
495+
MAX_USER_SIZE
496+
);
487497
Ok(Self {
488498
udf_path: udf_path_canonicalized,
489-
udf_args: ConvexArray::try_from(j.args)?,
499+
udf_args,
490500
cron_schedule: schedule,
491501
})
492502
}

0 commit comments

Comments
 (0)