| latte | by dg | docs: internals describe the traps of getIterator() and the JSON check of the sandbox 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | docs: sandbox internals describe the checks placed when printing and further boundaries 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: dynamic property name is converted to string once The name was converted for the check and again for the access, so an object whose __toString() returns a different name each time passed the check with an allowed name and read another property. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | SecurityPolicy: createSafePolicy() does not allow filters |query and |escapeJs (BC break) Both serialize an object with all its public properties, past the policy. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: filters |sort and |group read the property through the policy A name passed as 'by' or 'byKey' is read by the filter itself, where the sandbox does not see it. The sandbox replaces the name with a closure that reads the property with the policy check. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: objects are not encoded to JSON (BC break) json_encode() prints every public property of an object, past the policy: in <script>, in JavaScript attributes and templates, and for an array in data-* attributes and n:attr. The sandbox refuses an object there, even one nested in an array; HTML and trusted content is still printed as a string. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: loop tags call methods only on the iterator of {foreach} {first}, {last}, {sep}, {skipIf}, {iterateWhile} and {else} of {foreach} call methods of $iterator in generated code, which the sandbox pass does not see. A template could assign a host object to $iterator and have its isFirst(), next(), current() etc. called past the policy. PrintContext::isSandboxed() tells nodes that they print for the sandbox. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | tests: getIterator() of every node yields its children by reference 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | IfContentNode: n:else branch is visible to compiler passes 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | IterateWhileNode: assigns the {foreach} target as compiler passes left it The node kept its own copies of the key and value nodes of {foreach}, which getIterator() did not yield, so the sandbox checked the target in {foreach} only and {iterateWhile} wrote to it unchecked. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | BlockNode, DefineNode: name of a dynamic block is replaceable by compiler passes Block::$name was readonly, so getIterator() yielded it by value and a pass replacing the node lost its replacement: a custom function in the name was not resolved and the sandbox did not check the expression. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| security | by dg | updated upgrading.md | | | |
| security | by dg | User: added $onDecided, the Tracy panel lists every decision with the votes and marks those nobody decided 195806fd-c436-4445-84be-e0898ae821fd | | | |
| security | by dg | SecurityExtension: voter services are lazy, created on the first vote, so a voter may depend on the User 195806fd-c436-4445-84be-e0898ae821fd | | | |
| security | by dg | tests: MemoryStorage instead of MockUserStorage 195806fd-c436-4445-84be-e0898ae821fd | | | |
| security | by dg | added MemoryStorage, a user storage for tests and CLI scripts, configured as storage: memory 195806fd-c436-4445-84be-e0898ae821fd | | | |
| security | by dg | CookieStorage: the exception says the minimal length of UID 0187da3d-956c-4697-95c6-2c55eaa89a59 | | | |
| security | by dg | Principal: without roles, those of the identity or the guest identity are used 195806fd-c436-4445-84be-e0898ae821fd | | | |
| security | by dg | isAllowed() accepts the privilege as a case of an enum, voters receive it unchanged The case of an enum reaches the voters as it is, so a voter tells its own enum by instanceof and a case of another enum with the same value cannot pass. The ACL and the wrapped Authorizator, which work with names, reduce a case of a string-backed enum to its value and abstain on any other privilege. | | | |
| security | by dg | Principal: added isLoggedIn() and getGuestIdentity() isLoggedIn() is the way for a voter to say any logged-in user. getGuestIdentity() gives a voter the data of the guest identity, which getIdentity() and hasId() keep hiding for a guest. | | | |
| security | by dg | readme: authorization is described with voters | | | |
| security | by dg | User: $authenticatedRole is deprecated | | | |
| security | by dg | User::isAllowed() is final (BC break) | | | |
| security | by dg | User: authorization is decided by voters instead of an authorizator per role (BC break) Voters decide about the Principal of the user, the effective state: the identity only while logged in (unlike User::getId(), which keeps returning the retained identity after logout) and the effective roles. User::createPrincipal() decides about someone else than the current user, or about a visitor for null, taking the identity as it is; getPrincipal() is built on it. Permission is one of the voters; its vote() ORs the roles, forbids when an explicit deny rule stopped them and abstains when only the default deny-all did, as well as on roles and resources the ACL does not know instead of throwing. SecurityExtension adds every service implementing Voter to the user. setAuthorizator() and the getters are deprecated; the third parameter of the User constructor is a variadic list of voters, User::isAllowed() types the privilege as ?string. | | | |
| security | by dg | added Voter, Vote and Principal A Voter decides about a Principal: the identity of a logged-in user (null for a guest), the effective roles and the voters, so that a voter may delegate through $principal->isAllowed(). Ownership is checked by Principal::hasId(), which never matches for a guest. A vote is a Vote: a single Forbid wins, otherwise a single Allow suffices. Vote::allowIf() allows or abstains, so forbidding is always written on purpose. | | | |
| security | by dg | Role is deprecated, the core works with role names only (BC break) Roles are names. An identity returning a Role object throws InvalidStateException, Permission::isAllowed() accepts the role only as a string, and getQueriedRole() and getQueriedResource() return names, so an assertion decides by names only. Resource stays: it maps an entity to the name of an ACL resource, so the rules of that resource apply to the entity. | | | |
| security | by dg | AGENTS.md: added invariants of identity hooks and TokenIdentity | | | |
| security | by dg | SimpleIdentity: reading an undeclared property throws (BC break) Until now __get() returned null for an unknown key and, because it returns by reference, silently created that key in the data (and thus in the storage). It now throws MemberAccessException, like any other Nette object. This also ends the by-ref write pattern $identity->cart[] = $item on a key that has not been set yet. | | | |
| latte | by dg | updated upgrading.md | | | |
| latte | by dg | Runtime: added TrustedUrl, which is not checked in URL attributes A URL in href, src and other URL attributes is checked by checkUrl() and the only way around was |nocheck in the template, which turns the check off for the place whatever the value is. TrustedUrl moves the decision to the PHP code that creates the URL, e.g. one with a scheme of its own. It is not a content type: anywhere else it is escaped like any other value. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | FilterExecutor: contextual filters get TrustedJavaScript, TrustedCss & TrustedXml as a string of their type A contextual filter in a print, {$js|trim}, got an HTML object as a string with the content type html and its result was wrapped back; the other trusted types were passed as objects of an unknown type. They are now treated the same way: the filter gets the string with the type js, css or xml and the result becomes the trusted class of the type the filter left. The class of a content type and the type of a trusted object are mapped in Helpers::getTrustedClass() and getTrustedType() only. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | Engine: added renderToTrusted() Returns the output as the trusted object of the content type it really has, which removes the trap of new Html($latte->renderToString(...)), where nobody checks that the output is HTML. The type comes from the template that printed the output, which with {layout} is the last one of the chain, so Template::render() returns it. A single block has the type of the place it is defined in: a block in <script> gives TrustedJavaScript, in <style> TrustedCss, a block in <title>, <textarea> or an attribute is converted to HTML. A text or iCal template and a block without a conversion to its main type (a comment, on*) throw. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |