Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent sanitization: sanitize on output rather than input #4231

Closed
diosmosis opened this issue Oct 20, 2013 · 9 comments
Closed

Fix inconsistent sanitization: sanitize on output rather than input #4231

diosmosis opened this issue Oct 20, 2013 · 9 comments
Labels
c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Technical debt Issues the will help to reduce technical debt

Comments

@diosmosis
Copy link
Member

The way in which Piwik deals w/ sanitizing user data is inconsistent: it is sometimes done on input (data is stored sanitized), sometimes on output (less frequently). For example, website names are stored in the DB sanitized and need to be unsanitized or outputted raw in HTML. Goal names are not sanitized in the DB and need to be escaped when outputting in HTML.

This should be made consistent. Additionally, security best practices recommend:

  • filter on input (e.g. cast to an integer if you expect an integer, but don't sanitize strings)
  • escape on output

Problems with the current approach:

We should try to slowly move to sanitizing on output using native escaping features of Twig or AngularJS for example.

@mattab
Copy link
Member

mattab commented Oct 23, 2013

  • Search for {{ siteName| }}
    • SMS report encoding
    • All consumers of websiteName

Besides Website names, what are the other entities which are stored sanitized?

I expect maybe that many entities will store as sanitize. Fixing this has some risks for XSS we have to careful.

@mattab
Copy link
Member

mattab commented Mar 6, 2014

  • Also maybe we can remove the makeXssContent() used in tests and make the behavior consistent (ie. sanitize whether we call the API directly in PHP, or via HTTP, or whether we use API\Request object).

@diosmosis
Copy link
Member Author

@matt If makeXssContent is removed, how do we test for XSS?

@mattab
Copy link
Member

mattab commented Mar 7, 2014

I didn't mean to remove the xss test itself but rather I was noting that there is also an inconsistency in the way APIs inputs are (or not) sanitized.
Maybe this is out of scope for this ticket though.

@mattab
Copy link
Member

mattab commented May 24, 2015

Note: there is another inconsistent sanitization policy in Piwik, see below function:

    /**
     * This function will sanitize or not if it's needed for the specified action type
     *
     * URLs (Page URLs, Downloads, Outlinks) are stored raw (unsanitized)
     * while other action types are stored Sanitized
     *
     * @param $actionType
     * @param $actionString
     * @return string
     */
    private static function normaliseActionString($actionType, $actionString)

and: Action::isActionTypeStoredSanitized

@diosmosis diosmosis modified the milestones: 3.0.0, Mid term May 26, 2015
@mnapoli mnapoli changed the title Remove inconsistent sanitization (site name stored sanitized, goal name isn't, etc.) Fix inconsistent sanitization: sanitize on output rather than input May 29, 2015
@mnapoli
Copy link
Contributor

mnapoli commented May 29, 2015

#6714 has been merged into this issue

@mnapoli mnapoli added the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label May 29, 2015
@mattab mattab removed the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Oct 1, 2015
@mattab mattab modified the milestones: Mid term, 3.0.0 Jul 8, 2016
@mattab mattab added the c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. label Jul 8, 2016
@rogogon
Copy link

rogogon commented Feb 16, 2017

@mattab hi, as this problem is open for a long time and commonly suffered, when do you plan to fix it?

@mattab
Copy link
Member

mattab commented Feb 16, 2017

Due to the complexity of this task and the high risk of introducing security regressions (in particular, XSS), so far we have not been able to work / schedule this project. I would suspect it will take a long time before we can tackle this fully, and likely it will be done step by step over time, plugin by plugin etc. Any contribution will be very welcome

@mattab
Copy link
Member

mattab commented Dec 11, 2023

Thanks for creating this issue! We appreciate your input. This issue covers a lot of ground, and it's a bit too broad for us to tackle effectively as is. So, we're going to close it for now.

Instead some issues still opened are: #11786 #21164 #9223

@mattab mattab closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Technical debt Issues the will help to reduce technical debt
Projects
None yet
Development

No branches or pull requests

5 participants