Commit 6ff96b5
committed
fix(pirania): fix global variable leaks and shell injection in utils.lua
getIpv4AndMac() leaked six global variables (fd, ipv4mac, fd6, ipv6mac,
fd4, ipv4) that could corrupt state across concurrent CGI requests in
uhttpd's Lua runtime. Add local declarations to all of them.
Also add IP address validation before passing to shell commands. The
ip_address parameter (from REMOTE_ADDR) was concatenated directly into
grep commands without sanitization. A crafted value could execute
arbitrary commands. validate_ip() now restricts input to characters
valid for IPv4 (digits, dots) or IPv6 (hex, colons, brackets).1 parent dc8f1aa commit 6ff96b5
1 file changed
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
41 | 58 | | |
42 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
43 | 63 | | |
44 | 64 | | |
45 | 65 | | |
46 | | - | |
47 | | - | |
| 66 | + | |
| 67 | + | |
48 | 68 | | |
49 | 69 | | |
50 | 70 | | |
51 | 71 | | |
52 | 72 | | |
53 | 73 | | |
54 | 74 | | |
55 | | - | |
56 | | - | |
| 75 | + | |
| 76 | + | |
57 | 77 | | |
58 | 78 | | |
59 | | - | |
60 | | - | |
| 79 | + | |
| 80 | + | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
| |||
0 commit comments