Skip to content
SecurityIntermediate5 questions

Spot the security bug

Injection, mass assignment, output escaping and password storage in everyday Laravel code.

  1. 01What is wrong with this query?
    $email = $request->input('email');
    
    $users = DB::select("SELECT * FROM users WHERE email = '$email'");
  2. 02The users table has an is_admin column and the model sets $guarded = []. What is the risk in this controller action?
    public function store(Request $request)
    {
        return User::create($request->all());
    }
  3. 03A comment is rendered like this in a Blade view. What is the problem?
    <div class="comment">
        {!! $comment->body !!}
    </div>
  4. 04A Blade form posts to a route in the web middleware group and the response is "419 Page Expired". What is missing?
    <form method="POST" action="/profile">
        <input type="text" name="name">
        <button type="submit">Save</button>
    </form>
  5. 05Which line stores a new user's password safely?

Answers are scored on the server. Unanswered questions count as incorrect.

laravel.now is an independent community project. It is not affiliated with, endorsed by, sponsored by, or in any way officially connected to Laravel, Laravel LLC, Taylor Otwell, or the Laravel framework maintainers. Laravel is a trademark of Taylor Otwell. All other trademarks belong to their respective owners.

This site is operated by the makers of Lockhound. Links to Lockhound are promotional.