[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[TEST PATCH] Minor denial of service attack

From: Kieran <kieran_at_esperi.demon.co.uk>
Date: 2002-07-31 06:33:03 CEST

Hi,

It appears that setting a property on a directory prevents running
"svn commit" in that directory. I've got tests in both shell and
python below. (I think the shell version is a little easier to follow)

<start>
#!/bin/bash

CUR=`pwd`
REPO=$CUR/test-repo
WC=$CUR/test-wc

rm -rf $REPO $WC

echo Create repository at $REPO
svnadmin create $REPO

echo Checking out to $WC
svn co file://$REPO $WC

echo Changing dir to $WC
cd $WC

echo Creating file 1
cat <<EOF > testfile1
$Author$
$Date$
EOF

echo Creating file 2
cat <<EOF > testfile2
$Date$
$Author$
Mossad surveillance NSA
EOF

sleep 2
echo "Adding file to repository: *"
echo "svn add `ls $WC`"
svn add test*

sleep 2
echo "Random directory fin"
svn propset svn:keywords .

echo "Commmiting new files"
svn commit -m "import of crud"

<snip>

A solution to the locking prob is to run "svn revert" on the directory,
or explicitly list (excluding the directory) the resources being
commited. Haven't tried playing with more than one directory.

Haven't had time to look at the source yet. I haven't created an issue,
because I'm not sure what the correct behaviour in this situation is.

Regards

Kieran

<start of test patch>
Test for possible denial of service attack using "svn propset"
on a directory
* subversion/tests/clients/cmdline/prop_tests.py: added test
  "check_commit_after_directory_property_setting"

Index: subversion/tests/clients/cmdline/prop_tests.py
===================================================================
--- subversion/tests/clients/cmdline/prop_tests.py
+++ subversion/tests/clients/cmdline/prop_tests.py Wed Jul 31 05:17:25 2002
@@ -521,6 +521,71 @@
                                                None, None, None, None, None,
                                                1)

+# There is sometimes a problem where commits are blocked when
+# properties are set on a directory
+def check_commit_after_directory_property_setting(sbox):
+ "Checks on random acts by users setting properties on directories"
+
+ # Bootstrap
+ if sbox.build():
+ return 1
+
+ wc_dir = sbox.wc_dir
+ was_cwd = os.getcwd ()
+
+ os.chdir (wc_dir)
+
+ # This tells subversion to set the property of translating text in
+ # the actually directory file. It is an invalid action, but
+ # caused probs when this test was being written
+
+ # The behaviour seen was that after svn propset on the directory,
+ # svn commit complained about the directory being locked.
+ open('testfile', 'w').write("This is a test")
+
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'add', 'testfile')
+ if (len(stderr_lines) != 0):
+ os.chdir (was_cwd)
+ return 1
+
+ # This should fail, hence the 0
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'propset', 'svn:keywords', '.')
+ if (len(stderr_lines) != 0):
+ os.chdir (was_cwd)
+ return 0
+
+ ## The following code is left in for debugging...
+ # stdout_lines, stderr_lines = \
+ # svntest.main.run_svn (None, 'status', '-v', '-u')
+ # print stdout_lines
+ # print stderr_lines
+
+ # This is were the problem occurs: the commit fails, The error
+ # given is "svn_error: #21043 : <Attempted to lock an already-locked dir>"
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'commit', '-m', 'Commit message')
+ if (len(stderr_lines) == 0):
+ os.chdir (was_cwd)
+ return 0
+
+ # In theory, this should "make it better"
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'cleanup')
+ if (len(stderr_lines) != 0):
+ os.chdir (was_cwd)
+ return 1
+
+ # Does commit work after cleanup???
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'commit', '-m', 'Commit message')
+ if (len(stderr_lines) == 0):
+ os.chdir (was_cwd)
+ return 0
+
+ os.chdir (was_cwd)
+ return 1

 ########################################################################
 # Run the tests
@@ -536,6 +601,7 @@
               update_conflict_props,
               commit_replacement_props,
               revert_replacement_props,
+ check_commit_after_directory_property_setting,
              ]

 if __name__ == '__main__':

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jul 31 06:34:16 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.