Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@
**Vulnerability:** In `package/network/config/netifd/files/lib/netifd/utils.uc`, the `handler_load` function iterates over `.sh` scripts in a directory and uses their `basename` to execute them via a string interpolated `system()` call (`system("./${script} ...")`). If an attacker could place a maliciously named file in the parsed directory (e.g., `$(touch \/tmp\/pwned).sh`), it would result in arbitrary command execution.
**Learning:** In `ucode` scripts, `system()` with a string argument is executed by the shell (`/bin/sh -c`). When using variables derived from filenames or external sources within these string templates, failure to sanitize allows shell metacharacter injection.
**Prevention:** To protect `system()` or `fs.popen()` when string interpolation is unavoidable, always strictly validate variables using regex allowlists (e.g., `if (match(script, /[^a-zA-Z0-9_.-]/)) continue;`) to ensure only safe characters are evaluated by the shell.
## 2026-05-22 - [Fix buffer overflow risk in AR8327 LED driver]
**Vulnerability:** Unbounded `strcpy` used for copying dynamic string into flexible array member without reusing precalculated length.
**Learning:** In kernel modules, `strcpy` should be replaced with `strscpy`, and size variables should be precalculated to avoid TOCTOU races between allocation and copying.
**Prevention:** Use `strscpy` with a precalculated length variable instead of `strcpy` and `strlen`.
6 changes: 4 additions & 2 deletions target/linux/generic/files/drivers/net/phy/ar8327.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ ar8327_led_create(struct ar8xxx_priv *priv,
{
struct ar8327_data *data = priv->chip_data;
struct ar8327_led *aled;
size_t name_len;
int ret;

if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS))
Expand All @@ -318,7 +319,8 @@ ar8327_led_create(struct ar8xxx_priv *priv,
if (led_info->led_num >= AR8327_NUM_LEDS)
return -EINVAL;

aled = kzalloc(struct_size(aled, name, strlen(led_info->name) + 1),
name_len = strlen(led_info->name) + 1;
aled = kzalloc(struct_size(aled, name, name_len),
GFP_KERNEL);
if (!aled)
return -ENOMEM;
Expand All @@ -332,7 +334,7 @@ ar8327_led_create(struct ar8xxx_priv *priv,
if (aled->mode == AR8327_LED_MODE_HW)
aled->enable_hw_mode = true;

strcpy(aled->name, led_info->name);
strscpy(aled->name, led_info->name, name_len);

aled->cdev.name = aled->name;
aled->cdev.brightness_set = ar8327_led_set_brightness;
Expand Down
Loading