Skip to content

question: Alternative to ValidateIf due to Security breachΒ #2606

Open
@zant23

Description

@zant23

I was trying to make a form builder validation for backend service.
In this i have data occur dependant on the user choice. As Further input depends on previous choices i have conditional fields that need to be present e.g.

{
vehicleType: "truck" | "car"
carData?: "car Specific Props"
truckdata?: "TruckSpecific Props"
}

The problem:

With ValidateIf i could check that the either carData or truckData is present based on vehicleData.
But it still leaves me with the security breach that teh other one is not type checked at and therefore prune to inject any data in the json.

e.g.

{
vehicleType: "truck",
truckData: "TruckData"
carData: "Mailicious Json" ❌
}

Is there any clean and secure solution to this problem with class-validator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions