Escaped output and the 1.1.1 upgrade
Version 1.1.1 is a security release. Three changes in it close holes in the shipped markup and in the profile rules, and one of them needs your hands on an existing site — not because the fix is incomplete, but because the files it fixes belong to you.
1.1.1 is not published yet
Everything on this page is already in the component's source and in core/components/pbauth/docs/changelog.txt, but the package has not been built yet. In the Installer the newest version is still 1.1.0. Read this page now if you are planning the upgrade; there is nothing to download yet.
What changed
| What | Where |
|---|---|
| Everything a visitor typed is printed escaped | 21 of the 22 shipped templates — all the form chunks, their modal copies, the social buttons, both account e-mails and the auth wrapper |
| The avatar path is set by the server, never by the request | rules.profile, form.profile.tpl, ProfileController |
The profile's username rule rejects markup characters | rules.profile |
The first one is the one that matters here. Up to 1.1.1 not a single shipped template had |escape on it, and Fenom does not escape on its own — PageBlocks starts the engine without auto_escape. So a name, a full name, an e-mail or a phone carrying markup was written into the page as markup.
Why this was not merely self-XSS
The profile alone would be the visitor's own business. /impersonate/{id} makes it everybody's: a manager with the sudo flag signs in as any user, and the manager and the front end share one PHP session. A name typed by an ordinary visitor is therefore printed in the administrator's browser, on the same origin, in a session that holds a manager-context token. That is a privilege escalation, not a self-inflicted one.
Why an escaping fix does not reach a working site on its own
The page is rendered from the copy in core/App/elements/auth/, not from the one inside the component. Templates are called through the file: provider, which is pointed at pageblocks_elements_path — {core_path}App/elements/ by default. The component's own elements/ folder is never read while a page is being rendered. It is a source for the installer and nothing else.
And up to 1.1.1 the installer never overwrote an existing file in core/App/: once it landed there, it was the site's. Both halves are reasonable on their own, and together they meant the escaping fix would only ever reach a fresh install — never an upgrade, that is, never the sites it was written for.
What the upgrade does now
The resolver tells its own untouched copy apart from a file you edited, using the hashes in core/App/.pbauth-installed.json. Four outcomes per file:
State of the file in core/App/ | What the upgrade does | Log |
|---|---|---|
| not there at all | copies the shipped one | counted in the INFO summary |
| present and byte-identical to the shipped one, or recorded in the manifest with an unchanged hash | replaces it with the shipped one | counted in the INFO summary |
| present and edited by the site | leaves it exactly as it is | one WARN line, naming the file |
| its own copy, but the overwrite failed | leaves it as it is | one ERROR line, naming the file |
A plain install still overwrites nothing: there is either no file, or a file that is the site's.
So the version's fixes reach every file you did not touch, automatically. The files you did touch stay yours — still carrying the old markup, and still printing names raw.
Read the upgrade log. The WARN lines are your files
This is the one step that is not optional. After the upgrade, open System → Error log in the manager, or read core/cache/logs/error.log, and look for lines starting with [pbAuth] App/:
[pbAuth] App/elements/auth/chunks/form.login.tpl правлен сайтом и оставлен
как есть — правки этой версии в него не попали. Сверьте его с
core/components/pbauth/elements/auth/chunks/form.login.tpl вручную.One line per file. The installer prints these in Russian regardless of the manager language; the reliable thing to search for is the [pbAuth] App/ prefix.
A green installer console does not mean you are done
The console says the package installed. It says nothing about which of your files were skipped. If you never look at the log, an edited form.login.tpl keeps the hole and nobody finds out.
Every file named in a WARN line has to be compared, by hand, against the shipped original at the same path under core/components/pbauth/. An ERROR line means the same thing with a different cause — the file is the component's, but it could not be written. Check the file permissions and run the upgrade again.
What to add to a chunk you had edited
Put |escape on every print of a value. There is no list of exceptions: pbAuth has no deliberate markup anywhere — no ready-made HTML coming out of PHP, no tags in the labels, in any of the four languages. If it prints a value, it gets escaped.
Three groups to walk through in each chunk:
<!-- what was typed and came back after a validation error -->
value="{$old_input.email|escape}"
<!-- error and status texts -->
<span class="invalid-feedback" data-error="email">{$errors.email|escape}</span>
<p class="form-message" pb-message>{$success_message|escape}</p>
<!-- current values, the avatar, the name in the manager's view -->
<img src="{$avatar|escape}" alt="{$modx->user->username|escape}">The brackets around ?: are not a matter of style
A Fenom modifier binds to the last operand only. The profile form prints a current value with a fallback, and written the obvious way the fix does nothing:
<!-- WRONG: escapes the fallback, prints what was submitted raw -->
value="{$old_input.fullname ?: $up->fullname|escape}"
<!-- RIGHT: the whole expression is wrapped -->
value="{($old_input.fullname ?: $up->fullname)|escape}"The wrong version looks fixed. All four such prints in the shipped form.profile.tpl are wrapped whole, and this was measured on the engine, not reasoned about.
The labels file is in the same boat
core/App/lang/{ru,en,uk,de}/auth.php is copied by the same resolver, so an edited labels file is skipped the same way and gets its own WARN line. For this version that has a visible consequence: 1.1.1 adds one new key — the message for the username rule.
lang() reads core/App/lang/<locale>/auth.php and nothing else; there is no fallback to the component's copy, and a missing key is printed as the key itself. So on a site with an edited labels file, a visitor who types a < into their name is told:
auth.username_forbidden_charsAdd the key by hand, to every language your site uses:
// ru
'username_forbidden_chars' => 'Имя не может содержать знаки < > " \' &',
// en
'username_forbidden_chars' => 'The name cannot contain the characters < > " \' &',The shipped wording for all four languages is in core/components/pbauth/lang/{ru,en,uk,de}/auth.php.
The avatar: the form now sends an intent, not a path
Before 1.1.1 rules.profile had 'photo' => 'nullable|string', and the form returned the current path in a hidden field — otherwise "Delete photo" would have had nothing to clear. That pair was the hole: the avatar path could simply be submitted, and fromArray() wrote any string it was given into the profile. An upload only overwrote the value when a file actually arrived, so a request without a file went straight through.
Escaping did not close this and could not: such a value never breaks out of the attribute, but the picture is still chosen by whoever sent the request. On a site with a forum it is then printed next to other people's posts and handed to the thumbnail handler.
Now the path is set by the server only — from store() on upload, or to an empty string on delete — and the form answers one question: delete the picture or not.
If you had edited form.profile.tpl, two things in it are now wrong:
<!-- REMOVE: the path must not travel in the form -->
<input type="hidden" name="photo" value="{$photo|escape}">
<!-- ADD: the intent -->
<input type="hidden" name="delete_photo" value="">and the delete button must raise the flag instead of clearing the path:
document.querySelector('#auth-profile [name=delete_photo]').value = '1'For integrations: photo is now in $validated only when it changed
photo has no rule at all any more, and Validator::validated() builds its result by walking the rules, not what was submitted. So "do not touch the avatar" comes out as the key simply being absent — which is the behaviour you want, and a change for any listener on USER_SAVING or AFTER_PROFILE_UPDATE that read $validated['photo'] unconditionally. The current value is still available: the same events are handed the $profile object itself.
The username rule in the profile
Registration was already strict (alpha_dash:ascii), the profile was not — it was required|unique. That asymmetry was the hole: you could not register as <img src=x onerror=…>, but you could rename yourself to it. The ban is now on the profile rule as well, and it is deliberately a ban on five characters rather than a whitelist.
The rule and the reasoning behind it are in the rules reference: "The profile username rule".
The rule is a second line, not the defence
XSS is closed by escaping in the templates — guarded by tests/templates-escaping.php in the component's sources. The rule is there so that a name cannot break the markup in the places where somebody prints it without |escape: your own site template, a letter, a window in the manager. Which is also why you should not rely on it instead of escaping your chunks.
Checking whether your site is covered
From the site root, three questions:
# 1. Which of your files did the upgrade skip? (or read the log)
grep -r '\[pbAuth\] App/' core/cache/logs/error.log
# 2. Does any of your chunks still print a value unescaped?
grep -rn '{\$old_input\|{\$errors\.' core/App/elements/auth/ | grep -v escape
# 3. Does your profile form still send the avatar path?
grep -rn 'name="photo"' core/App/elements/auth/Empty output from the second and third is what you want. The first one lists exactly the files to compare by hand.
Where to go next
- Reference → Upgrading and uninstalling — the manifest, what uninstalling removes, moving from versions before 1.1.0.
- Your own fields in the forms — the validation rules, including the
usernamerule and the avatar fields. - Events and your own code — what reaches a listener in
$validated.
Questions about a specific upgrade: help@pageblocks.pro or Telegram @boshnik.