Serving websites from svn checkout considered harmful

简介:

Serving from a working copy

A simple way to update sites is to serve them from Subversion working copies. Checkout the code on the server, develop and commit changes, then svn update the server when you’re ready to release.

Security concerns

There’s a potential security problem with this. Subversion keeps track of meta-data and original versions of files by storing them in .svn directories in the working copy. If your web server allows requests that include these .svn directories, anything within them could be served to whoever requests it.

Requests would look like:

http://example.com/stuff/.svn/entries
http://example.com/stuff/.svn/text-base/page.php.svn-base
http://example.com/stuff/.svn/text-base/settings.py.svn-base

The first one would reveal some meta-data about your project, such as file paths, repository urls and usernames.

The second one may be interpreted as a PHP script, in which case there’s little risk. Or it may return the PHP source file, which is a much bigger risk.

The third one (assumed to be a Django project) should never happen. The request can only be for files within the web server’s document root. Code itself doesn’t need to be there, only media files do.

Alternatives

Instead of serving sites from a working copy, you can use svn export to get a “clean” copy of the site which does not include .svn directories. If you svn export from the repository, you must export the complete site, rather than just update the changed files, which could be a lot more data.

However, you can svn export from a working copy on the server. It’s still a complete export, but you don’t have to trouble the repository, so it’s typically much quicker.

An alternative is to update a working copy which is stored on the server, but not in the web document root, then use rsync or some file copying to update the “clean” copy in the web document root. In this case, only changed files are affected.

Protection through web server config

If you do serve from working copies, you should configure the web server to block all requests which include .svn in the url. Here’s how to do it for some popular web servers:

Apache

<LocationMatch ".*\.svn.*">
    Order allow,deny
    Deny from all
</LocationMatch>

Lighttpd

$HTTP["url"] =~ ".*\.svn.*" {
  url.access-deny = ("")
}

Nginx

Using the location directive which must appear in the context of server.

 

















本文转hackfreer51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/767864,如需转载请自行联系原作者

相关文章
|
8月前
|
数据库管理
Mac检出svn checkout报错 svn: E200030: SQLite 编译为 3.39.5,但是运行于 3.39.4
Mac检出svn checkout报错 svn: E200030: SQLite 编译为 3.39.5,但是运行于 3.39.4
348 0
svn checkout 实用小技巧
svn checkout 实用小技巧
335 0
|
数据安全/隐私保护 Linux 存储
|
数据安全/隐私保护
svn的revert、checkout、clean up、setting
svn revert 描述恢复所有对文件和目录的修改,并且解决所有的冲突状态。 svn revert不会只是恢复工作拷贝中一个项目的内容,也包括了对属性修改的恢复。最终,你可以使用它来取消所有已经做过的预定操作(例如,文件预定要添加或删除可以“恢复”)。
1493 0
svn只能checkout
<div style="font-family:微软雅黑; font-size:14px; line-height:21px"> <div style="background-color:inherit">svn只能checkout,不能commit、update等。重装、换版本均无效。</div> </div> <div style="font-family:微软雅黑; font-
1336 0
|
8月前
|
Ubuntu 安全 网络安全
百度搜索:蓝易云【Ubuntu系统SVN服务器搭建教程】
现在,你已经成功在Ubuntu系统上搭建了SVN服务器。其他用户可以通过SVN客户端连接到你的SVN服务器,进行代码版本管理和协作开发。注意,为了安全起见,建议配置SSL加密以保护数据传输。
90 1
|
8月前
|
存储 网络协议 Ubuntu
Linux环境下的SVN服务器搭建并结合内网穿透实现远程连接
Linux环境下的SVN服务器搭建并结合内网穿透实现远程连接
248 0