Skip to content

Add pw change page /password/ - #91

Merged
ArendJan merged 7 commits into
mirte-robot:developfrom
ArendJan:password-change-page
Sep 29, 2026
Merged

ArendJan merged 7 commits into
mirte-robot:developfrom
ArendJan:password-change-page

Conversation

@ArendJan

@ArendJan ArendJan commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@ArendJan
ArendJan requested review from mklomp and a lite review from Copilot September 9, 2026 09:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The nginx config as added is invalid (nested location) and the password-change endpoint currently has critical server-side security issues (shell injection + missing server-side whitelist validation).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new /password/ page and backend endpoint intended to let users change the MIRTE password via the web interface, and wires it into nginx + install script so it’s deployed on the robot image.

Changes:

  • Add a static HTML password-change page that POSTs JSON to a backend endpoint.
  • Add a PHP endpoint that updates the mirte user password via su/chpasswd.
  • Expose /password/ via nginx and copy the new site into /var/www/html/ during install.
File summaries
File Description
sites/password/index.html New UI for changing the password and toggling password visibility.
sites/password/change_password.php New PHP endpoint to validate inputs and run the password change command.
sites/401.html Adds a link to the new password page from the 401 page.
nginx.conf Adds routing intended to serve /password/ and execute PHP.
install_web.sh Installs php-fpm and copies the new /password/ site to the web root.
Review details

Suppressed comments (1)

sites/password/index.html:83

  • Same issue for the new password field: type="input" makes the password visible by default and misaligns the toggle button state. Use a password input and mark it as a new password for browser password managers.
                <input type="input" id="new-password" name="new-password" required>
                <button type="button" class="toggle-password" data-target="new-password">Hide</button>
  • Files reviewed: 5/5 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread nginx.conf
Comment thread sites/password/change_password.php

// su will return after a few seconds if incorrect, otherwise it's 'instantaneous' and the old password was correct.
// return code 0 means success, other means failure (incorrect old password)
exec("echo $old_password | su -c \"echo mirte:$new_password | sudo chpasswd \" mirte", $out, $return_var);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArendJan : Why didn't you apply this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's already 'safe' as the regex checks it. But I'll add it to be 100% sure!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was afraight that the escapeshellarg would add " or ' to the string, messing up mirte:$new_password for chpasswd, but it works!

Comment thread sites/password/change_password.php Outdated
Comment thread sites/password/index.html Outdated
Comment thread sites/password/change_password.php

@mklomp mklomp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good for now, as it solves our problem when we run the workshops. Two things that we might need to change for future implementations:

  1. Maybe change implementation language?

But more imoirtantly:

  1. In the current setup we give the ability to change the default password when it is connected to a shared network. So basically anyone can also change the password (since they know the default one). I think the actual check should not be the ability to change the password. I think we should not allow connecting to other networks as long as the password was not changed. This of course is easy for the web interface, but probably harder when connecting to a network through the commandline.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, PHP is fine for now. But in the future we might want to refactor this to a language we are already running on the MIRTE (eg pyhon or maybe nodejs).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When connecting with the commandline, you already had to change it (ssh), except with vscode, then that requirement isn't there.

@ArendJan
ArendJan merged commit ce3a284 into mirte-robot:develop Sep 29, 2026
12 checks passed
@ArendJan
ArendJan deleted the password-change-page branch September 29, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants