mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 10:31:14 +00:00
[AZ-809] F-AZ809-1: cap geofences.polygons at 50 (security audit)
Closes the cycle-8 Medium DoS finding. Without the cap, an authenticated caller could submit millions of bbox polygons in a single 500 MiB request (Kestrel global limit) and saturate the FluentValidation allocator on the validator hot path; each polygon is ~90 bytes of JSON, so the body limit is not a useful gate. Realistic use is 1-10 polygons per route — 50 leaves 5x headroom while bounding the worst-case allocation. Layers: - CreateRouteRequestValidator: MaxPolygons = 50 + Must(...) chained before RuleForEach so the count error fires at "geofences.polygons" (not the leaf path). - Unit: Validate_GeofencePolygonsTooMany_FailsCountRule. - Integration: GeofencePolygonsTooMany_Returns400 (51 valid bbox polygons -> HTTP 400 + errors["geofences.polygons"]). - Contract: route-creation.md -> v1.0.1 patch (tightening an existing range). New Inv-10, new geofence-polygons-too-many test case, changelog row. - Test spec: BT-29 sub-case 9b + AZ-809 AC-1b row in the traceability matrix. - Security report: F-AZ809-1 marked RESOLVED in cycle 8; verdict remains PASS_WITH_WARNINGS (Lows + carry-overs unchanged). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,6 +27,15 @@ public sealed class CreateRouteRequestValidator : AbstractValidator<CreateRouteR
|
||||
private const int MaxPoints = 500;
|
||||
private const int MaxNameLength = 200;
|
||||
private const int MaxDescriptionLength = 1000;
|
||||
// Geofences are axis-aligned bbox rectangles used for AOI restriction
|
||||
// during route planning (see route-creation.md). Realistic use is 1-10
|
||||
// polygons per route; cap at 50 to give 5x headroom while bounding the
|
||||
// validator's worst-case allocation. The global Kestrel body limit
|
||||
// (500 MiB, sized for the UAV upload endpoint) is not a useful gate
|
||||
// here because polygon JSON is small (~90 bytes per minimum-shape
|
||||
// polygon); without this cap a single authenticated request could
|
||||
// submit millions of polygons and saturate the LOH.
|
||||
private const int MaxPolygons = 50;
|
||||
|
||||
public CreateRouteRequestValidator()
|
||||
{
|
||||
@@ -74,6 +83,8 @@ public sealed class CreateRouteRequestValidator : AbstractValidator<CreateRouteR
|
||||
RuleFor(req => req.Geofences!.Polygons)
|
||||
.NotNull().WithMessage("`geofences.polygons` is required when `geofences` is present.")
|
||||
.NotEmpty().WithMessage("`geofences.polygons` must contain at least 1 polygon when `geofences` is present.")
|
||||
.Must(polygons => polygons is null || polygons.Count <= MaxPolygons)
|
||||
.WithMessage($"`geofences.polygons` must contain at most {MaxPolygons} polygons.")
|
||||
.OverridePropertyName("geofences.polygons");
|
||||
|
||||
RuleForEach(req => req.Geofences!.Polygons)
|
||||
|
||||
Reference in New Issue
Block a user