浏览代码

Fix SQL injection in table.php

Cast $drg to int before interpolating into queries. The variable comes
from $_GET['drg'] in the parent file and was previously unsanitised.
The ?? 0 fallback handles the include-file case where $drg may not yet
be set in the calling scope.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Benjamin Harris 2 周之前
父节点
当前提交
282004ba92
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      table.php

+ 2 - 1
table.php

@@ -1,8 +1,9 @@
 <?php
 require_once 'connection.php';
 
+$drg = (int)($drg ?? 0);
 
-$result = mysqli_query($con, " SELECT * FROM `details` WHERE  drg = $drg ORDER BY drg ASC ");
+$result = mysqli_query($con, " SELECT * FROM `details` WHERE drg = $drg ORDER BY drg ASC ");
 
 
 if (!$result) {