diff --git a/runtime/fastly/builtins/cache-core.cpp b/runtime/fastly/builtins/cache-core.cpp index 7a0bb32ba3..e42dd6e40d 100644 --- a/runtime/fastly/builtins/cache-core.cpp +++ b/runtime/fastly/builtins/cache-core.cpp @@ -612,6 +612,14 @@ bool CacheEntry::body(JSContext *cx, unsigned argc, JS::Value *vp) { } options.end = JS::ToUint64(end); } + + // Reject cases where the start is greater than the end. + // Ideally this would be a host-side check... but we didn't do it there to begin with, + // so we couple it to an SDK/runtime upgrade. + if (!start_val.isUndefined() && !end_val.isUndefined() && options.end > options.start) { + JS_ReportErrorASCII(cx, "end field is before the start field"); + return false; + } } auto res = handle.get_body(options);