RPO(Relative Path Overwrite)
- Conception(Relative vs Absolute)
Abosolute Path: “/etc/hosts”(in Linux),
“C:\Windows\System32\Drivers\etc\hosts”(in Windows)
Relative Path:”./hosts” or “hosts”(when in “etc” folder)
This also valid in website.
Absolute URL: “https://www.site.com/styles.css”
Relative URL in html:
In this case, the styles.css is a relative path in server’s root directory.
var/www/
|— index.html
|— styles.css
Using relative directory can be easier when has a complex file structure.
var/www
|— index.html
|— login
| |— login.php
| |— register.php
| |— pc.css
| |— mobile.css
|— static
|— js
| |— jQuery.js
| |— bootstrap.js
|— css
|— styles.css
In this case, we can load css using relative path like “pc.css”(Its absolute path is /login/pc.css)
- Example(A missing css style)
Client side(Incorrect url parse):
Considering the following urls:
www.site.com/login/login.php
www.site.com/login/login.php/
In server side, the two urls returns same page named index.php.
But as client side, the two urls differs from each other.
To load css style with relative urls, client requests resource as follows:
www.site.com/static/css/style.css
www.site.com/login/static/css/style.css
Obversely the second url is invalid which would return 404 from server when adding a forward slash.
In this case we can perform XSS without server side checking.
Server side(Incorrect server action and properties):
Some server framework like Apache and Nginx parse url differently.
Urls as follows:
www.site.com/login%2flogin.php
Apache would return 404 cause there is no file named login%2flogin.php, at the same time, Nginx would return the login.php page currectly.
- Get it work
We build a website structured as follows:
var/www/
|— index.php
|— styles.css
index.php
Hi, my name is .
Press the green button below to friend me and the red to cancel.
<button id=”green”>...</button>
<button id=”red”>...</button>
When accessing the page through https://www.site.com/index.php, the included stylesheet will be loaded from https://www.site.com/style.css. If the page is loaded through https://www.site.com/index.php/[anything] instead, the stylesheet will be loaded from https://www.site.com/index.php/style.css.
As stated before, the URL router on the server side will ignore everything after friend.php/ and the included stylesheet will therefore be loaded from the page itself. By changing the name on a vulnerable social network, the attacker can control the value of name and, consequently, the stylesheet.
We can get valid CSS within the HTML page by putting “{}” in front of the CSS, so the result is this:
https://www.site.com/index.php?name={}#green{background-color:red;}#red{background-color:green;}
The button intended to be green is now red.
- Share your mind(CTF Writeup)
Write article section to post text, Overview section to view text, Reports section to post url to bot.
The source code contents following segment:
Which has a RPO attack exploit with a relative path.
So we can exploit it this way:
Write article section to post a XSS file. Then edit a url using PRO exploit with Overview section’s text as malicious JavaScript. Bot will access malicious JavaScript after post the RPO url.
- Additional Information
Phpinfo url mode:
https://www.site.com/login/login.php/u/user/p/pass
This url is equivalent as
https://www.site.com/login/login.php?u=user&p=pass
补充2018/4/14
RPO简介:
RPO(Relative Path Overwrite) 攻击又称为相对路径覆盖攻击,利用的是nginx服务器、配置错误的Apache服务器和浏览器之间对URL解析出现的差异,并借助文件中包含的相对路径的css或者js造成跨目录读取css或者js,甚至可以将本身不是css或者js的页面当做css或者js解析,从而触发xss等进一步的攻击手段。
RPO原理:
上文英文详细介绍。
RPO漏洞触发前提:
①Apache 配置错误导致AllowEncodedSlashes这个选项开启(对Apache来说默认情况下 AllowEncodedSlashes 这个选项是关闭的),或者nginx服务器。
如何理解:
在Nginx服务器下,当我们访问“http://rpo.com/test/..%2fshow.php”时,nginx服务器默认会返回“http://rpo.com/show.php”页面并显示,这是因为在nginx的路由解析中,“%2f”是url编码过的“/”,这就意味着“..%2f”会被解析成退回上级目录,所以造成了跨目录调用。
在apache服务器下,nginx的情况默认不会出现,相反apache会将“..%2fshow.php”当做是一个文件然后去访问,肯定访问不到返回404。而当apache服务器配置文件中AllowEncodedSlashes=true时,上面的跨目录调用会复现。
②存在相对路径的js或者css的引用
如何理解:
一般情况下我们访问css或者js静态资源时会使用类似"http://rpo.com/test/style.css"的绝对路径进行访问。但是一个网站如果想要迁移更方便或者开发者为了省事,通常会使用相对路径的静态资源加载,例如“http://rpo.com/test/show.php”想要加载test目录下的style.css样式文件,会使用“style.css”直接进行访问。当使用相对路径的资源调用时,就有可能会有rpo漏洞。
漏洞利用实例:
待补充
RPO(Relative Path Overwrite)的更多相关文章
- Security Report: Stop using relative path to import CSS files
Detecting and exploiting path-relative stylesheet import (PRSSI) vulnerabilities Early last year G ...
- How to put a relative path for a DLL statically loaded?
How to put a relative path for a DLL statically loaded? I have a DLL made in Delphi 7/Windows XP tha ...
- Hive报错 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:user.name%7D
报错信息如下 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyn ...
- hive启动时报错 java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D at org.apache.hadoop.fs.Path.initialize
错误提示信息如下 错误信息如下 [root@node1 bin]# ./hive Logging initialized -bin/lib/hive-common-.jar!/hive-log4j.p ...
- c# Relative Path convert to Absolute Path
Reference: http://stackoverflow.com/questions/4796254/relative-path-to-absolute-path-in-c http://sta ...
- firefox ie 比较 relative path
relative path 对于firefox ie 来说是不同的 在ie中 <base href="/">起基础url作用 此时 <a href="& ...
- FAILED java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI:hdfs:192.*
运行的参数配置 hdfs:192.168.58.180/cf/userItem.txt 应该写成 hdfs://192.*
- Caused by: java.net.URISyntaxException: Relative path in absolute URI
<property> <name>hive.exec.scratchdir</name> <value>/tmp/hive</value> ...
- Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bhive.session.id%7D_resources
原因:环境变量设置问题 <property> <name>Hive.exec.local.scratchdir</name> <value> ...
随机推荐
- 手写ButterKnife
开发中使用注解框架可以极大地提高编码效率,注解框架用到的技术可以分为两种,运行时注解跟编译时注解.运行时注解一般配合反射机制使用,编译时注解则是用来生成模板代码.这里我们分别使用这两种方法实现Butt ...
- PHP微信公众平台oauth2.0网页授权登录类的封装demo
一.微信授权使用的是OAuth2.0授权的方式.主要有以下简略步骤: 第一步:用户同意授权,获取code 第二步:通过code换取网页授权access_token 第三步:拉取用户信息(需scope为 ...
- Eclipse项目中web app libraries和 Referenced Libraries区别
Referenced Libraries是编译环境下使用的JAR包,所谓编译环境下使用的JAR包, 就是说你在Eclipse中进行源文件的编写的时候,所需要引用到的类都从Referenced Li ...
- 关于css的text-indent首行缩进两个字符和图片缩进的问题
段落前面空两个字的距离,不要再使用空格了.应该使用首行缩进text-indent. text-indent可以使得容器内首行缩进一定单位.比如中文段落一般每段前空两个汉字. <style typ ...
- php缩放gif和png图透明背景变成黑色的解决方法_php技巧
工作中需要缩放一些gif图然后在去Imagecopymerge,可是发现使用了imagecreatetruecolor和imagecopyresampled后发现背景图不对,本来透明的背景图变成了黑色 ...
- (译文)学习ES6非常棒的特性-字符串常量基础
字符串常量基础 在ES2015之前我们是这么拼接字符串的: var result = 10; var prefix = "the first double digit number I le ...
- java————面向对象概念
面向对象 OO:面向对象 OOP:面向对象编程 OOA:面向对象分析 OOD:面向对象设计 面向对象的特征 继承,封装,多态 什么是对象? 对象是存在的具体实体,具有明确定义的特征和行为. 万物皆对象 ...
- 2017-2018-1 20155215 第五周 mybash的实现
题目要求 使用fork,exec,wait实现mybash 写出伪代码,产品代码和测试代码 发表知识理解,实现过程和问题解决的博客(包含代码托管链接) 学习fork,exec,wait fork ma ...
- maven添加oracle驱动
由于oracle商业版权问题,maven是不可以直接下载jar包的,所以.. 先将ojdbc14.jar放到用户目录,win7放到C:\Users\Administrator然后在cmd执行 ...
- Connect Appium Server Fail.A new session could not be created
1.由于安卓测试机性能低下,并不能支持测试工作,想安装一个模拟器帮助测试,然后发现群里有朋友发了一个夜神模拟器..下载..安装..美滋滋的准备运行脚本.What..居然报错了..orz..然后百度查找 ...