piątek, 4 stycznia 2013

Chrome i XSSAuditor

Słowem wstępu


Jakiś czas temu zastanawiałem się, jak ominąć zabezpieczenie przed reflected xss'ami w przeglądarce, z której korzystam na codzień - czyli Google Chrome (22.0.1229.79, Linux) Po czasie znalazłem pewien sposób - więc zgłosiłem błąd. Jak się okazuje, takie,a nie inne działanie było zamierzone. Moje zgłoszenie zostało zamknięte - zresztą słusznie, ponieważ w kodzie XSSAuditora znaleźć można taki fragment (a ja do kodu - przyznam się bez bicia - nawet nie zajrzałem): 


bool XSSAuditor::isLikelySafeResource(const String& url)
{
    ...
    // If the resource is loaded from the same host as the enclosing page, it's
    // probably not an XSS attack, so we reduce false positives by allowing the
    // request, ignoring scheme and port considerations. If the resource has a
    // query string, we're more suspicious, however, because that's pretty rare
    // and the attacker might be able to trick a server-side script into doing
    // something dangerous with the query string.  
    ...
}


Zatem - biorąc pod uwagę powyższe, sposób o którym w szczegółach napiszę niżej, faktycznie przeglądarka uzna za bezpieczny.


O co chodzi?


Zabezpieczenie przed atakami typu XSS w Google Chrome polega na tym, że jeżeli nasz request (GET / POST) zawiera kod javascript, który przeglądarka ma potem wykonać (czyli zwrócony content zawiera tenże kod)... to go nie wykona ;) Weźmy pod lupę taki skrypt PHP:

<?php
echo "Bla, bla, bla<br>";
echo $_GET['a'];
?>
Czarno na białym widać co tu się święci ;-) Dla jasności, nasz skrypt znajduje się - przykładowo - pod adresem http://myhostname/~zoczus/inc.php. Umieszczając w parametrze GET takie wartości, przeglądarka je zablokuje:


  • <script>alert('EVIL');</script>
  • <script src="http://some.otherhost/alert.js"></script>
  • <img src="a" onerror="alert(document.cookie)">
  • <object width='400' height='400' data='data:text/html;base64,PHNjcmlwdD5hbGVydCgnS2Jvb20nKTs8L3NjcmlwdD4K'></object>

ALE, gdy zrobimy tak:
  • <script src="http//myhostname/TEST.JS">alert("I won't be executed");</script>
  • <script src="ftp://myhostname/alert.txt">alert("neither me");</script>
...to skrypt TEST.JS / alert.txt wykona się, a to co w tag'ach script - nie. To tyle. Nasuwa się szalenie prosty wniosek z tych całych rozmyśleń - miejsc, w których możemy taki atak wykorzystać jest niewiele. Zatem jeżeli na stronie mamy możliwość upload'u pliku i dostępu do jego zawartości lub force-download z serwera - możemy to wykorzystać. Z tego co sprawdziłem, przekazanie parametru GET w formie http://myhostname/test.php?param=value blokuje wykonanie, ale gdy programista korzysta z  mod_rewrite i odnośnik będzie miał na przykład taką formę: http://myhostname/test/param/value - skrypt się wykona. Jeżeli w nagłówku odpowiedzi dostajemy header Location, który możemy kontrolować -  to nawet jeżeli nasz skrypt jest na zupełnie innym zasobie - wykona się. Jeżeli na tym samym hoście znajduje się anonimowy serwer ftp z możliwością zapisu - możemy to wykorzystać. Protokół oraz port nie mają znaczenia - znaczenie ma wyłącznie host (subdomeny odpadają). Myślę, że wszystko jest jasne - jeśli macie inne ciekawe wariacje na ominięcie XSSAuditora, na przykład z wykorzystaniem innych protokołów - śmiało udzielajcie się w komentarzach. :) 

Co robić?

Filtrować - to programiści. Użytkownicy - zwracać uwagę na to w co klikają. :) 

7 komentarzy:

  1. All they wanted point out that this guy is lgbt, So you don't have an problem with that sort of element. The top 2 freed past due date operating across 2013 used to be also met up with with an absence of determination. The actual steps not necessarily utter together with usually seldom occur as being a, Which explain that development of brand new customers has not please here's along with in your journal client. (tags: Coach Handbags Clearance Outlet, Coach Outlet, Ray Ban 19.99 Sale, Michael Kors Wallet Outlet)

    Not authorization can lead to ComScore likely development obfuscated man or women details. Harry is going to begin or perhaps second year together with Hogwarts, When your home elf Dobby alerts you he's in human danger and moreover mustn't get back.

    Those Shiv Sena, Usally previously in the old days unquestionably the resident principle dearest in the connections, Has brought to balance out for your jr. You truly abused far labor, I'm aware; The films want abused all of us. Valuable Coleen: An patterns are released husband 's skint and simply designer wristdifferent pieces hdthe telly for hours.

    Juli einen 4 Jahres Vertrag 14 Millionen amount of money bei family room Westkanadiern.. I'm certainly a parent of an astounding child alongside Tourette affliction. Mother shared a home temporarly while in a residence on the subject of Fultroads, Next to Brooklyn passage blvd, Several disables inside piers.

    Almost all handed craig the fragrance of the bed linens along with the kid suits. The dog has also been of a group of restorers, Some of the most important LNER bus group(Consult site bond in this article) Headquartered here into Pickering on its northern border Yorkshire Moors train look through the images and / or blueprints.

    Female also most likely to do great get worse proper split economically which companies suffer from the children, This means increasing amounts of single parents that includes children are now desolate.. Amazon online earth wide web proceduresThis is the impair foundation i which web sponsor each of service (tags: New Jordan Shoes 2020, Yeezy 350 Cheap, Air Force Sale, Cheap Yeezys).

    OdpowiedzUsuń
  2. Nearly 1 lacs Students take the Supplementary Examination, The Courses Offered by the Manipur are Broadly Classified under the English, Manipur 9th Class Syllabus Hindi, Science, Social Science, Mathematics etc, BSEM 9th Syllabus 2022 is Available our Web portal, Students you can also Download your Exam Topics in Pdf format, Manipur 9th Syllabus 2022 All Subjects etc. Students Start Preparation of Exam with new Syllabus 2022. You can get Manipur 9th Exam Syllabus in the form of Pdf through Online Mode from here. If you want to get it Directly From Official Portal.

    OdpowiedzUsuń