1. 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)

  1. 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.

  1. 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.

  1. 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.

  1. 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)的更多相关文章

  1. Security Report: Stop using relative path to import CSS files

    Detecting and exploiting path-relative stylesheet import (PRSSI) vulnerabilities   Early last year G ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. c# Relative Path convert to Absolute Path

    Reference: http://stackoverflow.com/questions/4796254/relative-path-to-absolute-path-in-c http://sta ...

  6. firefox ie 比较 relative path

    relative path 对于firefox ie 来说是不同的 在ie中 <base href="/">起基础url作用 此时 <a href="& ...

  7. FAILED java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI:hdfs:192.*

    运行的参数配置 hdfs:192.168.58.180/cf/userItem.txt 应该写成 hdfs://192.*

  8. Caused by: java.net.URISyntaxException: Relative path in absolute URI

    <property> <name>hive.exec.scratchdir</name> <value>/tmp/hive</value> ...

  9. Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bhive.session.id%7D_resources

    原因:环境变量设置问题 <property>    <name>Hive.exec.local.scratchdir</name>    <value> ...

随机推荐

  1. Matlab绘图基础——绘制三维曲线

    %% 绘制三维曲线 %plot3函数,其中每一组x,y,z组成一组曲线的坐标参数,选项的定义和plot函数相同. %1.当x,y,z是同维向量时,则x,y,z 对应元素构成一条三维曲线. x0 = 0 ...

  2. CentOS 6.5 通过命令行安装发送邮件

    1.安装sendmail: yum install sendmail 2.安装mailx: yum install mailx -y 3.编辑发送的配置文件: vi /etc/mail.rc #在最后 ...

  3. DirectSound---捕获音频、Qml/C++ 集成交互

    DirectSound的音频捕获原理和播放原理差不多,内部在一个缓冲区上循环写入捕获到的数据,并且提供notify通知功能. 1. 音频捕获 因为捕获流程和播放流程类似,我们就不在这里赘述了,只给出简 ...

  4. 初学MySQL基础知识笔记--01

    本人初入博客园,第一次写博客,在今后的时间里会一点点的提高自己博客的水平,以及博客的排版等. 在今天,我学习了一下MySQL数据库的基本知识,相信关于MySQL的资料网上会有很多,所以我就不在这里复制 ...

  5. 记录python接口自动化测试--requests使用和基本方法封装(第一目)

    之前学习了使用jmeter+ant做接口测试,并实现了接口的批量维护管理(大概500多条用例),对"接口"以及"接口测试"有了一个基础了解,最近找了一些用pyt ...

  6. Beta冲刺NO.5

    Beta冲刺 第五天 1. 昨天的困难 1.昨天的困难主要是在类的整理上,一些逻辑理不清,也有一些类写的太绝对了,扩展性就不那么好了,所以,昨天的困难就是在重构上. 页面结构太凌乱,之前没有统筹好具体 ...

  7. 结对开发五--对一千个数long型的一维数组求最大子数组的和

    一.设计思想 我们根据第一个实验,再让他自动生成1000个随机long型数.大致思想和实验一一样,自己已埋入炸弹. 二.实验代码 package com.minirisoft; import java ...

  8. spring mvc 整合Quartz

    Quartz是一个完全由java编写的开源作业调度框架.不要让作业调度这个术语吓着你.尽管Quartz框架整合了许多额外功能, 但就其简易形式看,你会发现它易用得简直让人受不了!Quartz整合在sp ...

  9. win7开启wifi

    在启用本地共享连接时,出现的错误! 我已经建了一个无线临时网络,来启用共享用来上网的!Internet连接共享访问被启用时,出现了一个错误(null)?而且这错误也会在系统日志里留下记录,都是些莫名其 ...

  10. 咬碎STL空间配置器

    STL空间配置器 一.开场白: 给我的感觉就是,了解是空间配置器的功能,是那么的明了:在看原理,我还是很开心:接下来是360度大转变: 那么长的变量或者函数命名.那么多的宏.不爽,不过,遇上我这种二货 ...