Upgrade to Pro — share decks privately, control downloads, hide ads and more …

本当にあった怖い脆弱性の話

Roku
April 10, 2022

 本当にあった怖い脆弱性の話

PHPerkaigi 2022 Day2 Track B

Roku

April 10, 2022
Tweet

More Decks by Roku

Other Decks in Programming

Transcript

  1. 썪썝썰쎢ɻ 쎕썱쏟쎫쎮쏵쎆 ඇެ։ྖҬ쎂ஔ썤ɺ 쏰썗쏀*%౳썿썿쎙쎂 %#쎂อଘ public function upload(Request $request) {

    //ϦΫΤετऔಘ $uploaded_file = $request->file('upload'); //…தུ… //privateσΟεΫʹอଘ $save_path = $uploaded_file->store('userfiles'); //DBʹอଘ $private_file = new PrivateFile(); $private_file->user_id = Auth::id(); $private_file->file_path = $save_path; $private_file->mime_type = $uploaded_file ->getMimeType(); $private_file->save(); //ϓϨϏϡʔ༻ʹURLΛฦ٫ return response()->json([ 'url' => route('private-file', [ $private_file->file_id, $uploaded_file->extension() ]), ]); }
  2. 썪썝썰쎢ɻ 쎽쏽쏒쏷썗쏳 썢쎠쏟쎫쎮쏵쎩 ฦ٫ public function view(PrivateFile $private_file, string $ext)

    { //ϢʔβIDνΣοΫ if ($private_file->user_id !== Auth::id()) { abort(404); } //ଘࡏνΣοΫ if (!Storage::exists($private_file->file_path)) { abort(404); } //Ϩεϙϯε $headers = ['Content-Type' => $private_file->mime_type]; $content = Storage::get($private_file->file_path); return response($content, 200, $headers); }
  3. 썪썝썛썝࢓༷썷썿ཧղ ೖۚೖྗ ೖۚ֬ೝ ܾࡁը໘ 8FCIPPL Τϯυ ϙΠϯτ ܾࡁ׬ྃ ࢒ߴߋ৽ "1*

    쏴쏊쎮쏶쎹쏒 ຊ쏁쏃쏐쏪 ֎෦ܾࡁ쎿쎮쏒 ผ쏁쏃쏐쏪 8FCIPPL 쎽썗쏵 ೖۚ༧ఆ 쏑썗쏉ొ࿥ ೖۚࡁ 쎂ߋ৽
  4. 썪썝썛썝࢓༷썷썿ཧղ ೖۚೖྗ ೖۚ֬ೝ ܾࡁը໘ 8FCIPPL Τϯυ ϙΠϯτ ܾࡁ׬ྃ ࢒ߴߋ৽ "1*

    쏴쏊쎮쏶쎹쏒 ຊ쏁쏃쏐쏪 ֎෦ܾࡁ쎿쎮쏒 ผ쏁쏃쏐쏪 8FCIPPL 쎽썗쏵 ೖۚ༧ఆ 쏑썗쏉ొ࿥ ೖۚࡁ 쎂ߋ৽ ܾࡁ͕׬શ֎෦ͳΒ ܾࡁ৘ใอ࣋PS௨աͱ͔ͷ ৺഑͸ͳ͍͚Ͳɺ ҰԠ͚ͩ͜͜ݟͱ͔͘ɻ
  5. 쏇썗쏃쏋쎱쏍쎹 public function webhook(Request $request) { //ϦΫΤετऔಘ $deposit_id = $request->input('rid');

    $tran_id = $request->input('tid'); $tran_date = $request->input('tdt'); //֘౰ͷೖۚ༧ఆΛऔಘ $deposit = Deposit::find($deposit_id); if (!$deposit_id) { abort(400); } //σʔλΛߋ৽ $deposit->status = Status::SUCCESS; $deposit->tran_id = $tran_id; $deposit->tran_date = $tran_date; $deposit->save(); //ӡ༻γεςϜͷ࢒ߴՃࢉ (API) DataLinkService::add($deposit->user_id, $deposit->amount); //ਖ਼ৗϨεϙϯε die("0"); }
  6. public function webhook(Request $request) { //ϦΫΤετऔಘ $deposit_id = $request->input('rid'); $tran_id

    = $request->input('tid'); $tran_date = $request->input('tdt'); //֘౰ͷೖۚ༧ఆΛऔಘ $deposit = Deposit::find($deposit_id); if (!$deposit_id) { abort(400); } //σʔλΛߋ৽ $deposit->status = Status::SUCCESS; $deposit->tran_id = $tran_id; $deposit->tran_date = $tran_date; $deposit->save(); //ӡ༻γεςϜͷ࢒ߴՃࢉ (API) DataLinkService::add($deposit->user_id, $deposit->amount); //ਖ਼ৗϨεϙϯε die("0"); } 쎙썝Ұ౓
  7. 쏤쎮쏷썗쏓쎂ਖ਼썮썛 lSJEz썬썟썙쎣쎇ɺ ແ৚݅쎂ೖۚࡁ썿 썮썽ॲཧ썬쎣쎢ɻ public function webhook(Request $request) { //ϦΫΤετऔಘ

    $deposit_id = $request->input('rid'); $tran_id = $request->input('tid'); $tran_date = $request->input('tdt'); //֘౰ͷೖۚ༧ఆΛऔಘ $deposit = Deposit::find($deposit_id); if (!$deposit_id) { abort(400); } //σʔλΛߋ৽ $deposit->status = Status::SUCCESS; $deposit->tran_id = $tran_id; $deposit->tran_date = $tran_date; $deposit->save(); //ӡ༻γεςϜͷ࢒ߴՃࢉ (API) DataLinkService::add($deposit->user_id, $deposit->amount); //ਖ਼ৗϨεϙϯε die("0"); } 쎙썝Ұ౓
  8. 썻쎕쎡썪썝썰쎢썿 ೖۚೖྗ ೖۚ֬ೝ ܾࡁը໘ 8FCIPPL Τϯυ ϙΠϯτ ܾࡁ׬ྃ ࢒ߴߋ৽ "1*

    쏴쏊쎮쏶쎹쏒 ຊ쏁쏃쏐쏪 ֎෦ܾࡁ쎿쎮쏒 ผ쏁쏃쏐쏪 8FCIPPL 쎽썗쏵 ೖۚ༧ఆ 쏑썗쏉ొ࿥ ೖۚࡁ 쎂ߋ৽ ܾࡁ썲썱쎂཭୤ DVSM91045ESJEIUUQT[BSV[BSVFYBNQMFDPNXFCIPPL
  9. 썪썪썣࠷େ쎅ةػ؅ཧ쏧쎮쏽쏒썺쎔썛쎅썾 ೖۚೖྗ ೖۚ֬ೝ ܾࡁը໘ 8FCIPPL Τϯυ ϙΠϯτ ܾࡁ׬ྃ ࢒ߴߋ৽ "1*

    쏴쏊쎮쏶쎹쏒 ຊ쏁쏃쏐쏪 ֎෦ܾࡁ쎿쎮쏒 ผ쏁쏃쏐쏪 8FCIPPL 쎽썗쏵 ೖۚ༧ఆ 쏑썗쏉ొ࿥ ೖۚࡁ 쎂ߋ৽
  10. 쎁쎪썸쎚쎠쎿썗쏝쏃썾HSFQ ͓΍ʁ ਵ෼γϯϓϧ͚ͩͲɺ ͜Ε࢖ͬͯΔͷʁ public function transaction(Request $request) { $amount

    = $request->input('amount'); $user_id = Auth::id(); //ӡ༻γεςϜͷ࢒ߴՃࢉ (API) DataLinkService::add($user_id, $amount); return ['success' => true]; }
  11. JEUSBOTBDUJPO썾HSFQ ͳΜ΍ ίϝϯτΞ΢τ͞ΕͱΔ΍ͳ͍͔͍ ͋ʔͼͬ͘Γͨ͠ɻ ͬͯɾɾɾ {{-- <form id=“transaction”> <div class="form-row">

    <div class="form-group col-md-6"> <label>ೖֹۚۚ</label> <input type="number" name="amount"> </div> </div> <button class="btn btn-primary">ೖۚ</button> </form> --}}
  12. BQJUSBOTBDUJPO쎆ੜ썤썽쎕썰ɻ 쏰썗쏀쏨쎮쏤썗쏂쎂쏷쎺쎮쏽썮썽썶쎠ୟ써쎕썰ɻ public function transaction(Request $request) { $amount = $request->input('amount');

    $user_id = Auth::id(); //ӡ༻γεςϜͷ࢒ߴՃࢉ (API) DataLinkService::add($user_id, $amount); return ['success' => true]; } Route::post('/api/transaction', [ApiController::class, 'transaction']);
  13. 쎕썘େৎ෉썺쎔썛 <div class="form-row align-items-end"> <div class="form-group col-md-6"> <label>ి࿩൪߸</label> <div>{{ $input->phone_1

    }}</div> </div> <div class="form-group col-md-6"> <label>ܞଳి࿩൪߸</label> <div>{{ $input->phone_2 }}</div> </div> </div> <div class="form-row align-items-end"> <div class="form-group col-md-12"> <label>උߟ</label> <div>{!! nl2br(e($input->note)) !!}</div> </div> </div>
  14. protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class,

    \Illuminate\View\Middleware\ShareErrorsFromSession::class, //\App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\RedirectIfHasProblem::class, ],