0
is the following, in the application I am developing, I have a complaint form where the user does not need is logged in to fill it and make his due complaint, up to there everything right, so he sends the data is displayed to him a (page)view with the information he filled out. However, once this page(view) is displayed with the information, the registration id is displayed in the url, and this way I am calling a security problem.
for example: if user made a registration is displayed to him the view with the information he registered and the following url http://127.0.0.1:8000/controlNote/exibeInformacaDeNote? data=40
but if the user passes another id manually in the url is displayed to him the data of that other complaint http://127.0.0.1:8000/controlNote/exibeInformacaDeNote? data=41
Obs: I’m using the framework
has some way to avoid this situation?
This is the controller responsible for calling and validating the report form
public function adiciona(){
return view('AdminDenunciaView.adicionaDenuncia');
}
public function adicionaAction(Request $request){
$request->validate([
'crime'=>['required','string'],
'descricao'=>['required','string','min:10','max:200'],
]);
$crime = $request->input('crime');
$descricao = $request->input('descricao');
$data = new Denuncia();
$data-> crime = $crime;
$data-> descricao = $descricao;
$data-> save();
return redirect()->route('exibeInformacaoDenuncia',['data'=>$data]);
}
This controller is responsible for calling the view with registered information
public function exibe(Request $id){
$data = Denuncia::find($id);
return view('AdminDenunciaView.exibeInformacaoDenuncia',['data'=>$data]);
}
hello Guilherme, very obg by the feedback, when trying to practice your tips in the mode displays() I get the following error Object of class Illuminate Http Request could not be converted to number
– frdmarkes
@frdmarkes ah got it, it was my mistake, 1 min
– Guilherme Nascimento
@frdmarkes corrected in response, the correct is:
public function exibe(Request $request, $id)
, sorry for the mistake.– Guilherme Nascimento
Hello William, once again, thanks for trying to help me. I’m getting another answer, check it out: it’s as if he expects to be passed only 1 parameter: Too few Arguments to Function App Http Controllers Admindenunciacontroller Information::displays(), 1 passed and Exactly 2 expected
– frdmarkes
@frdmarkes you changed the route to
Route::get('exibeInformacaoDenuncia/{dados}', ...
? Understand how route parameters work?– Guilherme Nascimento
I gave +1 for the first alternative, the second seems to make no sense. If you are always adding and subtracting 5000 (in this case), then instead change
/41
for/42
would trade/5041
for/5042
and would have the same result. No?– Inkeliz
Thanks dear @Inkeliz, about MASK_ID, I will try to elucidate me based on a question... what is the goal usually of someone who uses UUID as Ids? Even though this in some Sgdbs has a worse performance than using INTEGERS.
– Guilherme Nascimento
@Guilhermenascimento I think there are several objectives, but the main (in this case) would be to prevent access to other content. That is, if there was a
youtube.com/v/123
I could change to/124
and end up accessing a private video. This is a case similar to that of the OP. However, the sum and subtraction does not solve this problem, in my view. Since now you have/5041
and I can still change to/5042
, they remain sequential and easily accessible. Even if multiplied, they would continue sequentially (create two denunciations and that’s it). Or, I’m sleepy and I’ve lost some information. haha– Inkeliz
Dear @Inkeliz if numeric format had been a security breach for years it would have been abandoned, because if it is possible to access content that does not belong to you by changing the ID in the URL then the problem is not the format but the application ... actually the only problem that switching to UUID solves is to avoid people deducting the amount of items that exist from a type of information.
– Guilherme Nascimento
@Guilhermenascimento, the goal of the OP is precisely to hide the information and prevent others access the content, has no relation to quantity of item. He says: "but if the user manually passes another id in the url, the data of this other complaint will be displayed to him". I’m not talking about number format or not, but adding and subtracting as a way to prevent deducing other Ids does not solve the OP issue. The use of random Ids would prevent this (which is the same as the UUID order), at least it would have more work, mainly attached to a rate-limit, and other authentications (which the OP does not have).
– Inkeliz
@Inkeliz and therefore I said at the beginning of the question, it does not make sense, it is not necessary.... the only utility that exists in this is only will be to deduce values, for other objectives so it is only lack of understanding, ID has the goal to identify something, you gain nothing hidden.
– Guilherme Nascimento