K 社は最近、一般向けサービス経由でセキュリティ侵害を経験しました。サーバー上のイベントを分析すると、次のコードにまでさかのぼることができます。 SELECT ' From userjdata WHERE Username = 0 and userid8 1 or 1=1;- 次のコントロールのうち、どれを実装するのが最適でしょうか?
正解:D
The code snippet provided suggests an SQL injection vulnerability, indicated by the use of "1=1," which is a common SQL injection technique to bypass authentication. To mitigate this risk, validating user input is the most effective control, as it ensures that any input is properly sanitized and escapes potentially malicious characters before interacting with the database. This is a key principle from CompTIA Security+ guidelines on secure coding practices. Options A and B are unrelated to the vulnerability type here, and while access control (Option C) is generally good practice, it does not specifically prevent SQL injection.