Stored Cross-Site Scripting occurs due to insufficient input sanitization and output escaping. Authenticated attackers with subscriber-level access and above can inject arbitrary web scripts into pages. This happens because the `permalink` parameter is processed using `sanitize url()`, which fails to prevent the fetching of remote URLs. The response body of these URLs, including script tags and event-handler attributes, is then written directly to disk using the `file put contents()` function.