You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenIPC web UI plugin: the camex settings page and init script - #223
Files for an OpenIPC camera that runs camex as a client, in examples/openipc-webui/:
plugin-camex.cgi, the settings page. It needs a web UI that lists plugin-*.cgi pages in its Services menu, which is separate work.
S98camex, the init script. It starts the client from the U-Boot environment, and only with camex_server and either camex_network or camex_psk with camex_pubkey.
README.md, with the variables and the build for a Cortex-A7 camera.
How the page works:
Save checks the values, writes all variables in one fw_setenv -s pass and restarts the client. Nothing is written when nothing changed, and values equal to their defaults (port, transport, MAC name) are not stored.
Reset stops the client and removes the camex_* variables.
Advanced shows the raw configuration, keys included, as the WireGuard page does. The psk is also visible in ps.
Values with control characters, spaces at the ends or &# are refused.
The page has no CSRF token of its own, like the web UI's WireGuard and VTun pages.
The init script closes inherited descriptors before it starts the client. Without that, a client started by Save kept the web server's devices and sockets open, and the deleted file with the form body.
Checked on an SSC325 camera (OpenIPC lite, static armv7 client 6.3.0, 297 KB): Save over UDP and TCP, refused values, a psk with special characters, Reset with the rest of the environment unchanged, and start at boot with the final script. shellcheck was run on the init script. There are no automated tests for these files.
No version change: no code or build files are touched.
Add OpenIPC camex settings page and camera init script
✨ Enhancement📝 Documentation🕐 20-40 Minutes
AI Description
• Add an OpenIPC settings page to validate, save, reset, and inspect camera client configuration.
• Start camex from U-Boot settings only when required connection details are present.
• Document installation, configuration variables, and a Cortex-A7 client build.
Merge Risk 🟡 Medium
Blast radius 🟢 Low💥 1 capability
1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
The CGI, persistent U-Boot environment, init script, and camex client form one bounded camera integration: the page writes the values, the init script reads them, and the client creates the remote-access tunnel.
These are producer, storage, and consumer hops of the same camera remote-access behavior rather than independent technical capabilities.
The broader OpenIPC UI runtime is external and not asserted as a separate affected scope.
if [ "$REQUEST_METHOD" = "POST" ] && [ "$POST_action" = "reset" ]; then
for v in $vars; do eval "$v="; done
$init stop </dev/null >/dev/null 2>&1
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be removed"
redirect_to "$SCRIPT_NAME" "danger" "Camex is down, its settings are removed"
elif [ "$REQUEST_METHOD" = "POST" ]; then
for v in $vars; do eval "$v=\$POST_$v"; done
: "${camex_port:=5800}" "${camex_transport:=udp}"
if check; then
# Defaults are not written, so they can change with camex
[ "$camex_port" = 5800 ] && camex_port=""
[ "$camex_transport" = udp ] && camex_transport=""
[ "$camex_name" = "$def_name" ] && camex_name=""
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be written"
$init restart </dev/null >/dev/null 2>&1
sleep 2
ready || redirect_to "$SCRIPT_NAME" "warning" "Saved. Camex starts with a server and a network name, or a server, its public key and a pre-shared key"
camex_pid
[ -n "$pid" ] || redirect_to "$SCRIPT_NAME" "danger" "Saved, but Camex is not running: see the log in Advanced"
redirect_to "$SCRIPT_NAME" "success" "Saved, Camex is restarted"
The change introduces more than a direct argument transformation.
Before: this repository had no shown OpenIPC camera configuration/lifecycle path.
After: submitted values are validated, defaults are selectively omitted, persistent environment state is compared and updated, reset stops the process before deletion, and restart starts the client only when server plus either network or public-key/PSK credentials are present.
Before: no such cross-step invariant existed.
After: the new correctness condition is that displayed/default values, stored U-Boot variables, init-script eligibility, and the arguments passed to camex remain mutually consistent across save, reset, restart, and boot/start transitions.
The existing camex validation and client argument handling are reused; their existence alone is not treated as complexity.
if [ "$REQUEST_METHOD" = "POST" ] && [ "$POST_action" = "reset" ]; then
for v in $vars; do eval "$v="; done
$init stop </dev/null >/dev/null 2>&1
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be removed"
redirect_to "$SCRIPT_NAME" "danger" "Camex is down, its settings are removed"
elif [ "$REQUEST_METHOD" = "POST" ]; then
for v in $vars; do eval "$v=\$POST_$v"; done
: "${camex_port:=5800}" "${camex_transport:=udp}"
if check; then
# Defaults are not written, so they can change with camex
[ "$camex_port" = 5800 ] && camex_port=""
[ "$camex_transport" = udp ] && camex_transport=""
[ "$camex_name" = "$def_name" ] && camex_name=""
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be written"
$init restart </dev/null >/dev/null 2>&1
sleep 2
ready || redirect_to "$SCRIPT_NAME" "warning" "Saved. Camex starts with a server and a network name, or a server, its public key and a pre-shared key"
camex_pid
[ -n "$pid" ] || redirect_to "$SCRIPT_NAME" "danger" "Saved, but Camex is not running: see the log in Advanced"
redirect_to "$SCRIPT_NAME" "success" "Saved, Camex is restarted"
Potential damage 🟡 Medium🩹 Temporary loss
If the added integration regresses while activated, the camera may fail to establish or maintain its Camex remote-access tunnel, leaving the remote web UI unavailable.
The supported recovery path is to correct the saved settings or rerun the init action; the source shows restart and stop behavior but does not establish automatic repair of malformed persistent state or compensation for any external access outage.
Reverting the code would not by itself undo already-written U-Boot environment values, although those values can be reset or overwritten through the page.
Recoverable by correcting or resetting the U-Boot-backed settings and restarting the client, assuming the camera remains administratively reachable.
If the tunnel is the only access path, recovery may require local access or another management channel.
No irreversible data mutation or external financial effect is shown.
if [ "$REQUEST_METHOD" = "POST" ] && [ "$POST_action" = "reset" ]; then
for v in $vars; do eval "$v="; done
$init stop </dev/null >/dev/null 2>&1
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be removed"
redirect_to "$SCRIPT_NAME" "danger" "Camex is down, its settings are removed"
elif [ "$REQUEST_METHOD" = "POST" ]; then
for v in $vars; do eval "$v=\$POST_$v"; done
: "${camex_port:=5800}" "${camex_transport:=udp}"
if check; then
# Defaults are not written, so they can change with camex
[ "$camex_port" = 5800 ] && camex_port=""
[ "$camex_transport" = udp ] && camex_transport=""
[ "$camex_name" = "$def_name" ] && camex_name=""
env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be written"
$init restart </dev/null >/dev/null 2>&1
sleep 2
ready || redirect_to "$SCRIPT_NAME" "warning" "Saved. Camex starts with a server and a network name, or a server, its public key and a pre-shared key"
camex_pid
[ -n "$pid" ] || redirect_to "$SCRIPT_NAME" "danger" "Saved, but Camex is not running: see the log in Advanced"
redirect_to "$SCRIPT_NAME" "success" "Saved, Camex is restarted"
graph TD
UI["Settings page"] --> V{"Valid settings?"} -->|save| E["U-Boot environment"] --> I["Init script"] --> R{"Ready to start?"} -->|yes| C["Camex client"]
UI -->|reset and stop| I
UI -->|reset and clear| E
R -->|no| X["Remain stopped"]
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Add client-side configuration-file support
➕ Could keep the pre-shared key out of the process command line and Advanced process listing.
➖ Requires changes to the client and deployment model, outside this example-only PR.
Recommendation: The U-Boot-backed page and init script fit the stated camera deployment and avoid changing the client. Keep this approach for the example, but treat command-line secret exposure as an explicit limitation; consider client-side configuration-file support separately. Integration also depends on the separate Services-menu plugin listing work.
Files changed (4) +271 / -0
Enhancement (2) +250 / -0
S98camexManage the camera client from U-Boot settings+88/-0
Manage the camera client from U-Boot settings
• Adds start, stop, and restart handling with a configuration readiness check, TUN loading, and PID tracking. Closes inherited descriptors before launching the client so a web-triggered restart does not retain web-server resources or the form body.
plugin-camex.cgiAdd the OpenIPC camex settings page+162/-0
Add the OpenIPC camex settings page
• Adds validated Save and Reset actions that batch U-Boot environment changes, omit default values, and manage the client. Displays connection status and an Advanced view of raw configuration and diagnostics, including keys.
1. Another site can reset camera settings 🐞 Bug⛨ Security
Description
plugin-camex.cgi accepts a reset POST based only on REQUEST_METHOD and POST_action, without
verifying that the request came from the settings page. If a camera administrator visits an
attacker-controlled page while authenticated to the web UI, a cross-site form submission can stop
the client and remove its saved settings.
+if [ "$REQUEST_METHOD" = "POST" ] && [ "$POST_action" = "reset" ]; then+ for v in $vars; do eval "$v="; done+ $init stop </dev/null >/dev/null 2>&1+ env_write || redirect_to "$SCRIPT_NAME" "danger" "The settings could not be removed"
Evidence
The reset branch checks only the POST method and action before stopping the service and calling the
settings writer; the reset form has no token field.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The new CGI accepts configuration-changing POSTs without verifying that they originated from its settings page, allowing cross-site requests to reset or replace camera settings.
## Fix Focus Areas
- examples/openipc-webui/plugin-camex.cgi[80-97]
- examples/openipc-webui/plugin-camex.cgi[131-144]
## Recommended Fix
Generate a session-bound, unpredictable request token in the page, include it in both POST forms, and verify it before either reset or save performs a write or service action.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Save now verifies the camex process via the new camex_pid helper after the restart and sleep, and
shows a danger message instead of success when the client is not running.
Description
plugin-camex.cgi discards the result of $init restart and uses ready(), which checks only
submitted settings, before displaying its success message. If the client binary is missing or exits
after launch, Save can report a successful restart even though the client is not running.
Added a check in check() that, when camex_server consists only of digits and dots, requires it to
match a four-octet IPv4 pattern where each octet is 0-255
(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]), and rejects a trailing dot. Invalid IPv4 literals such
as 999.999.999.999 now fail validation with "Server: not an IPv4 address" before being saved.
Description
check() validates camex_server with a character pattern and length limit, so it accepts an
invalid IPv4 literal such as 999.999.999.999. When that value is saved, the init script passes it
to the client, whose IPv4 endpoint resolution fails.
Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all
Cross-site POST: no change. The camera's web server refuses a POST whose Origin is another site before the page runs. Checked on the SSC325 camera: a POST with valid credentials and Origin: http://evil.example gets 403.
Failed start shown as success: fixed. After the restart the page checks that the client process is running, and says so when it is not. Checked with the binary moved away.
Invalid IPv4: fixed. A value made only of digits and dots must be an IPv4 address; 999.999.999.999 and 1.2.3 are refused. Checked on the camera.
Also: the unused loop variable shellcheck named in S98camex is gone.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not merge: waiting for the owner's review.
Files for an OpenIPC camera that runs camex as a client, in
examples/openipc-webui/:plugin-camex.cgi, the settings page. It needs a web UI that listsplugin-*.cgipages in its Services menu, which is separate work.S98camex, the init script. It starts the client from the U-Boot environment, and only withcamex_serverand eithercamex_networkorcamex_pskwithcamex_pubkey.README.md, with the variables and the build for a Cortex-A7 camera.How the page works:
fw_setenv -spass and restarts the client. Nothing is written when nothing changed, and values equal to their defaults (port, transport, MAC name) are not stored.camex_*variables.ps.&#are refused.The init script closes inherited descriptors before it starts the client. Without that, a client started by Save kept the web server's devices and sockets open, and the deleted file with the form body.
Checked on an SSC325 camera (OpenIPC lite, static armv7 client 6.3.0, 297 KB): Save over UDP and TCP, refused values, a psk with special characters, Reset with the rest of the environment unchanged, and start at boot with the final script.
shellcheckwas run on the init script. There are no automated tests for these files.No version change: no code or build files are touched.