oz11 Posted October 30, 2022 Share Posted October 30, 2022 (edited) .. Quickl easy question. $stmt = $pdo->prepare("SELECT *, count(*) FROM users WHERE forgotten_code=? LIMIT 1"); $stmt->execute([$_GET['reset']]); $check = $stmt->fetch(); if($check['count(*)'] > 0) { ... My thinking was that as its a PDO its not. Edited October 30, 2022 by oz11 Quote Link to comment https://forums.phpfreaks.com/topic/315474-is-this-segment-of-code-a-vulnerability/ Share on other sites More sharing options...
Solution Barand Posted October 30, 2022 Solution Share Posted October 30, 2022 It's poor SQL code. Any data returned by the "*" in the select will be meaningless. Because you are using an aggregation function the LIMIT is redundant - there will only be a single row containing the count. It is better to use a column alias for functions $stmt = $pdo->prepare("SELECT count(*) as total FROM users WHERE forgotten_code=?"); $stmt->execute([$_GET['reset']]); $check = $stmt->fetch(); if ($check['total'] > 0) { Quote Link to comment https://forums.phpfreaks.com/topic/315474-is-this-segment-of-code-a-vulnerability/#findComment-1602051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.