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

create list of best practices for preventing XSS vulnerabilities (Trac #3553) #3553

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 5 comments
Labels

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/3553 on 41440228-07-20 by cash, assigned to unknown.

Elgg version: 1.7

Elgg does a pretty good job with user submitted content that ends up in the database judging by reports and what I've seen in code.

Elgg has had a few problems with GET parameters that are used in page generation (think a search query) and has ignored parameters used in a URL section used in the same way. For example, I send Evan a link in the email:

Evan, check out the new plugin uploaded by Brett: http://community.elgg.org/pg/plugins/brettp/#hack

The #hack there is my stand in for a XSS attack. Let's say it rewrites the url for the download to point to a trojan horse.

The issue is that we often take a URL section and use it in a menu or use a GET parameter in a heading. The GET parameter should be going through the XSS filter so no really bad stuff should affect us there - just CSS modifications and image inserts. The use of URL segments are not going through get_input() (bad news).

Best practices:

  • any user input gets filtered and that includes url segments that are used in menu items or passed to page handler scripts
  • if we know we are looking for an int, it should be cast as an int
  • always grab variables and filter/cast at top of function/script
  • consider using dirty/clean variable names
  • consider using the action token in the ajax/view page handler

Additional functions:

  • add a function that parallels current get_input() but instead of putting stuff through htmlawed, it casts it to an int and returns. Better that sprinkling (int) throughout the code.
  • Besides passing GUIDs in URLs, we often pass usernames. Check if there is a function that we can use to filter or validate those before passing them on.
@elgg-gitbot
Copy link
Author

cash wrote on 41456376-02-01

We should publish these for 3rd party developers.

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.8.x by ewinslow on 41500444-06-21

@elgg-gitbot
Copy link
Author

Milestone changed to Documentation by cash on 42070205-05-12

@ewinslow ewinslow removed this from the Elgg 1.10.0 milestone Jun 13, 2014
@jdalsem
Copy link
Member

jdalsem commented Oct 23, 2014

Do we still need an Elgg specific list? There is also a general best practices list (that will be better maintained) https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29

@ewinslow
Copy link
Contributor

Elgg IMO is pretty poor when it comes to XSS best practices. I don't think documentation is the way to fix that. It feels like so far we've just gotten lucky.

What we need to do is design features of the framework such that it is very hard to do the wrong thing. There are other tickets for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants