Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 9, 2025
1 parent 143034f commit 0439e69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions database/cs/security.texy
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ $table = 'users';
$column = 'name';
$database->query('SELECT ?name FROM ?name', $column, $table);
// Výsledek v MySQL: SELECT `name` FROM `users`
```

Důležité: symbol `?name` používejte pouze pro důvěryhodné hodnoty definované v kódu aplikace. Pro hodnoty od uživatele použijte opět [whitelist|#Whitelist sloupců]. Jinak se vystavujete bezpečnostním rizikům:

```php
// ❌ NEBEZPEČNÉ - nikdy nepoužívejte vstup od uživatele
$database->query('SELECT ?name FROM users', $_GET['column']);
```

Důležité: symbol `?name` používejte pouze pro důvěryhodné hodnoty definované v kódu aplikace. Pro hodnoty od uživatele použijte opět whitelist. Jinak se vystavujete bezpečnostním rizikům, jako například dříve uvedený SQL enumeration nebo Mass Assignment Vulnerability.
6 changes: 4 additions & 2 deletions database/en/security.texy
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ $table = 'users';
$column = 'name';
$database->query('SELECT ?name FROM ?name', $column, $table);
// Result in MySQL: SELECT `name` FROM `users`
```

Important: Use the `?name` symbol only for trusted values defined in the application code. For values provided by the user, use a whitelist again. Otherwise, you risk security vulnerabilities:

```php
// ❌ DANGEROUS - never use user input
$database->query('SELECT ?name FROM users', $_GET['column']);
```

Important: Use the `?name` symbol only for trusted values defined in the application code. For values provided by the user, use a whitelist again. Otherwise, you risk security vulnerabilities, such as the previously mentioned SQL enumeration or Mass Assignment Vulnerability.

0 comments on commit 0439e69

Please sign in to comment.