Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E2A21200C7E for ; Tue, 23 May 2017 15:06:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E1397160BD6; Tue, 23 May 2017 13:06:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 09C36160BB6 for ; Tue, 23 May 2017 15:06:13 +0200 (CEST) Received: (qmail 23070 invoked by uid 500); 23 May 2017 13:06:07 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 23038 invoked by uid 99); 23 May 2017 13:06:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2017 13:06:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D55C9CEE9A for ; Tue, 23 May 2017 13:06:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.08 X-Spam-Level: X-Spam-Status: No, score=0.08 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=emerson.onmicrosoft.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Iz5E_lYogGjz for ; Tue, 23 May 2017 13:06:03 +0000 (UTC) Received: from esa5.emerson-outbound.iphmx.com (esa5.emerson-outbound.iphmx.com [68.232.143.91]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 490DC5F19B for ; Tue, 23 May 2017 13:06:02 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.38,382,1491264000"; d="scan'208";a="51947423" Received: from usstlz-pinfez07.extemr.org ([144.191.128.191]) by esa5.emerson-outbound.iphmx.com with ESMTP/TLS/AES128-SHA; 23 May 2017 13:22:10 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.19.249.34) by mail.emerson.com (10.16.8.80) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 23 May 2017 13:07:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emerson.onmicrosoft.com; s=selector1-Emerson-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+3pJkvhUZAG7gOgy05uqZY+SG8VUxYPuDqsqXCKhYVU=; b=kYLCTNDiZuZv34N37mFwpXSumOlaSlkLH0DPUiP6O7crkLKy6z2Dmzp2TZmg7AbbiPOjqz2iwYQB259jJ9IyM4f+nDUG3x0nrUf6fDmhRZLVZhVVSstRJ5MzEdHHBVuODthwpPwdSQJfdhSzj9vkVvuspetFY3cBnjBSNl0FNlg= Received: from BLUPR10MB0417.namprd10.prod.outlook.com (10.162.90.146) by BLUPR10MB0420.namprd10.prod.outlook.com (10.162.90.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Tue, 23 May 2017 13:05:16 +0000 Received: from BLUPR10MB0417.namprd10.prod.outlook.com ([10.162.90.146]) by BLUPR10MB0417.namprd10.prod.outlook.com ([10.162.90.146]) with mapi id 15.01.1101.019; Tue, 23 May 2017 13:05:16 +0000 From: "Cai, Charles [COMRES/RTC/RTC]" To: Tomcat Users List CC: "aw@ice-sa.com" Subject: RE: Question about Tomcat Virtual Host to prevent Improper-Input-Handling attack Thread-Topic: Question about Tomcat Virtual Host to prevent Improper-Input-Handling attack Thread-Index: AdLTKbixfcg3P//USnawag135w210QABpOoAACUmJqA= Date: Tue, 23 May 2017 13:05:15 +0000 Message-ID: References: <592339B2.4090202@ice-sa.com> In-Reply-To: <592339B2.4090202@ice-sa.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: tomcat.apache.org; dkim=none (message not signed) header.d=none;tomcat.apache.org; dmarc=none action=none header.from=Emerson.com; x-originating-ip: [144.191.148.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BLUPR10MB0420;7:D0mXYQJ8ouYEftPPbHkcae1LVVCM6jxiq3hp9fsYCoNayNZuxx1As2V9/abTXLTbpyrqQWH7CcU1+tDGRP7SzizTDgk6GklLXWvdZuVwfQrG6gsY2cOCSQwvd0INiHgyN88IGz4wLrf6E+OTro1sTwkUxP9HJgr0aKNcErLKQjnLHE6R9tb7U1TCvZcfz7oP25WVbCQZwAtvFcV/liEFtqRoQ/ekGfWePIBzF14CKeGYm/ZITGndx73cExGxsdaQXE5HkVNpRtFJBzJiALHNyALpdn1skaoI6+I7m79aetqd5pcaOWD+tLz5s57/W3NpVR3z+qH9sjMv0wla/lP0RA== x-ms-traffictypediagnostic: BLUPR10MB0420: x-ms-office365-filtering-correlation-id: 3088aabb-5d27-4002-fb07-08d4a1dc5b30 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075);SRVR:BLUPR10MB0420; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(236401367519767)(158342451672863)(265634631926514)(82395714480507)(185212123834332)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123555025)(20161123564025)(20161123560025)(6072148);SRVR:BLUPR10MB0420;BCL:0;PCL:0;RULEID:;SRVR:BLUPR10MB0420; x-forefront-prvs: 0316567485 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39450400003)(39410400002)(39860400002)(39840400002)(39850400002)(39400400002)(24454002)(13464003)(377454003)(45984002)(504964003)(252514010)(2900100001)(6436002)(4326008)(230783001)(6306002)(3280700002)(2906002)(33656002)(77096006)(66066001)(8676002)(5890100001)(81166006)(3660700001)(3846002)(72206003)(1720100001)(6506006)(7736002)(74316002)(7696004)(102836003)(966005)(6916009)(25786009)(2950100002)(305945005)(6116002)(86362001)(15974865002)(478600001)(8936002)(110136004)(55016002)(38730400002)(53546009)(50986999)(54356999)(76176999)(189998001)(99286003)(122556002)(5660300001)(229853002)(9686003)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR10MB0420;H:BLUPR10MB0417.namprd10.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2017 13:05:15.7923 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: eb06985d-06ca-4a17-81da-629ab99f6505 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR10MB0420 archived-at: Tue, 23 May 2017 13:06:15 -0000 Charles Cai | T +1 440 329 4888 -----Original Message----- From: Andr=E9 Warnier (tomcat) [mailto:aw@ice-sa.com]=20 Sent: Monday, May 22, 2017 3:19 PM To: users@tomcat.apache.org Subject: Re: Question about Tomcat Virtual Host to prevent Improper-Input-H= andling attack On 22.05.2017 20:35, Cai, Charles [COMRES/RTC/RTC] wrote: > Hi there, > > ______________________________________________________________________ > __________ > Server Specs: > Server version: Apache Tomcat/7.0.54 > Server built: May 19 2014 10:26:15 > Server number: 7.0.54.0 > OS Name: Windows Server 2012 > OS Version: 6.2 > Architecture: amd64 > JVM Version: 1.8.0_121-b13 > JVM Vendor: Oracle Corporation > ______________________________________________________________________ > __________ > > I'm currently on the process of trying fix a site vulnerability, basicall= y it is one type of the "Improper Input Handling" attack. > > Let's say my website is www.mywebsite.com and there is hacker's=20 > website www.hacker.com > > whenever there is a request send to www.mywebsite.com with modified "Host= " header point to www.hacker.com, my site will create a redirect to www.myw= ebsite.com along with whatever the url it was. e.g. > > Normal: > Host: www.mywebsite.com > GET www.mywebsite.com/get/some/resources/ > Response 200 ok > > Hack: > Host: www.hacker.com (#been manually modified) GET =20 > www.mywebsite.com/get/some/resources/ > Response 302 > Send another Redirect to www.hacker.com/get/some/resources My website=20 > is running on Tomcat 7, I tried some solution with set up the virtual hos= t by point the unknown host to a defaultlocalhost which supposed to do noth= ing. but it still send the redirect for some reason. > > Here attached is my server.xml host configure: > ______________________________________________________________________ > __________ jvmRoute=3D"jvm1"> unpackWARs=3D"true" autoDeploy=3D"false" deployOnStartup=3D"true= "> > > prefix=3D"localhost_access_log." suffix=3D".txt" > pattern=3D"%h %l %u %t "%r" %s %b" /> > > > > > ______________________________________________________________________ > __________ So, my question is, Am I on the right track to prevent this=20 > kind of attack ? If yes, what I did wrong that still not working? (The=20 > ultimate goal is, if it is not the legit Host that been passed in, the=20 > request should be discard/ignored/return 404 but not redirect with=20 > 302) > Hi. The first thing is, as far as I know, Tomcat *by itself* will not generate = this redirect response. But an application deployed inside Tomcat might do that, perhaps. With the above configuration, this is what happens : > > > 1) Any request coming in to your server, which has a Host: HTTP header whic= h is not "recognised" by Tomcat, will be processed by this "defaultlocalhos= t" virtual Host. See : http://tomcat.apache.org/tomcat-7.0-doc/config/engine.html#Attribute= s 2) this default virtual Host, as defined above, has an appBase=3D"webapps",= just like the other Host which you defined. That is because "webapps" is the *default* value for this attribute, and yo= u did not specify it otherwise in your "defaultlocalhost". See : http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Attributes 3) thus, if your normal application corresponding to the URI get/some/resou= rces/) is deployed under (tomcat_dir)/webapps, then your application will b= e called when anyone sends the following HTTP request to your server : GET get/some/resources/ HTTP/1.1 Host: evil.hackers.com (or whatever is not "www.mywebsite.com") What your application then does with this call, is up to your application. If it is some kind of framework, it might very well decide to return a redi= rect response. But that is not tomcat code. If you want to protect against this, then you should provide your "defaultl= ocalhost" with a real appBase, different from the standard "webapps", and m= aybe put a default application there which returns a lit cluster bomb to th= e evil hacker. (or more reasonably, a "not found" response; which tomcat will do by itself= if there is nothing there that matches the request URI). Note that in addition, with your above configuration, there should be warni= ngs in the tomcat logfile, because your application will be deployed twice = : once for the "defaultlocalhost" Host, and once for the "www.mywebsite.com= " Host. > Thank you in advance. > > More references about the attack here : > http://www.skeletonscribe.net/2013/05/practical-http-host-header-attac > ks.html=20 > http://projects.webappsec.org/w/page/13246933/Improper%20Input%20Handl > ing > > Original Post on stackoverflow: =20 > https://stackoverflow.com/questions/44054591/tomcat-virtual-host-to-pr > event-improper-input-handling-attack > > Charles Cai | Web Application Developer | RIDGID Emerson Commercial &=20 > Residential Solutions | Charles.Cai@emerson.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > That is , this is the issue, after I point the defaultlocalhost to a non-ex= isting webapp directory, it returned 404 instead of issue another redirect = with 302. Thank you very much. =20 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org