473,545 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Safe Local XMLRPC

Hi. I'm a user of python for about 3 years now. I've written a
client-server application that uses SimpleXMLRPCSer ver and
xmlrpclib.Serve rProxy to communicate. It's intended to be used by a
single-person as a backend and GUI frontend. I've got it running
great. Much stabler than my custom RPC I'd tried before.

I've used the default support available by these classes. Thus it will
run on a potentially public TCP/IP port. As the application backend
allows, among other things, saving files to the local filesystem, this
would be a clear security hole in the wild. Restricting it to
localhost would be a start, but not sufficient for multi-user systems.

It looks like it should be easy to modify both classes (or create
similar composite classes) that used unix-domain stream sockets. I
tried at one point and I think I got the server side, but without a
working client side it was impossible to tell. Is there a better way
to do this, or might someone point to references or sample code for
creating a unix-domain SimpleXMLRPCSer ver and xmlrpclib.Serve rProxy?

Thanks!
-m
Jul 18 '05 #1
6 5329
> I've used the default support available by these classes. Thus it will
run on a potentially public TCP/IP port. As the application backend
allows, among other things, saving files to the local filesystem, this
would be a clear security hole in the wild. Restricting it to
localhost would be a start, but not sufficient for multi-user systems.


This might not be the answer you want, but I'd personally ditch xmlrpc and
switch to something like pyro or even corba and implement a "real"
authentication theme. They are easy to use, provide a full OO-style
interface and are even faster than xmlrpc.

Part of the problems you're facing stem from the stateless nature of xmlrpc
(and soap, for that matter). That allows everybody to access the API
without prior authentication. It requires some effort to implement a
authentication/authorization scheme over xmlrpc. What usually is done in
xmlrpc in similar situations like yours is that there is a

authenticate(us er, password)

function that will return a handle on success that has to be passed to all
subsequent calls to other functions. All this because the handle can't be
associated with each and every xmlrpc request (in soap that can be done,
but its undstandarized. )

With corba/pyro, authenticate would return an object that implicitely has
all the state needed - nameley who created the connection - and then you
don't have to bother about that anymore.

Switching to pyro shouldn't be much more than a few lines of code, more or
less only subclassing your server from Pyro.core.ObjBa se instead of
SimpleXMLRPCSer ver.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
[Sorry, I previously replied to Diez offlist, and probably to a
spam-protected address at that. Here's that reply and my followup
after reading up on pyro
]
On Sat, 12 Mar 2005 11:08:31 -0600, Michael Urman <mu****@gmail.c om> wrote:
On Sat, 12 Mar 2005 14:12:21 +0100, Diez B. Roggisch <de*********@we b.de> wrote:
This might not be the answer you want, but I'd personally ditch xmlrpc and
switch to something like pyro or even corba and implement a "real"
authentication theme.


I don't have a problem with switching interfaces so long as I can keep
my (admittedly useless) feature of multiple simultaneous connections.
I am hoping to avoid writing an authentication method, as some slight
missteps there could lead to real trouble later; this is why I was
hoping to do unix-domain socket transports which I could just set to
read-write only by the owner on the filesystem itself.
With corba/pyro, authenticate would return an object that implicitely has
all the state needed - nameley who created the connection - and then you
don't have to bother about that anymore.


If I can get the authentication that I'm looking for that cheaply,
then this does indeed sound like the way for me to go. I'm not worried
about supporting remote connections, or anything of that nature, so
local identity is sufficient. I'll look into pyro; conveniently
there's a debian package for me to try.

Thanks Diez!
-m


Hmm. On inspection, pyro seems to be really heavy, what with its
requirement of a pyro-nameserver, and using TCP as the transport. I
think I'd still prefer convincing a variant of SimpleXMLRPCSer ver and
xmlrpclib.Serve rProxy to use unix domain sockets and using filesystem
security to limit access to the owner.

Thanks again,
-m
Jul 18 '05 #3
Thanks for your time everyone; I got it XMLRPC working over unix
domain stream sockets. In case people are interested, here's the
pieces I put together. I'm sure they throw away a little flexibility,
but they work for my purpose. Any pointers to make the code more
robust, or do less total overriding of should-be-arguments
appreciated.

-m

from SocketServer import UnixStreamServe r
from SimpleXMLRPCSer ver import SimpleXMLRPCDis patcher,
SimpleXMLRPCReq uestHandler
from xmlrpclib import ServerProxy, Fault, Transport
from socket import socket, AF_UNIX, SOCK_STREAM

# Server side is pretty easy - almost a direct copy of SimpleXMLRPCSer ver
SOCKPATH = 'testsock'
class UnixStreamXMLRP CServer(UnixStr eamServer, SimpleXMLRCPDis patcher):
def__init__(sel f, addr=SOCKPATH, requestHandler= SimpleXMLRPCReq uestHandler):
self.logRequest s = 0 # critical, as logging fails with UnixStreamServe r
SimpleXMLRPCDis patcher.__init_ _(self)
UnixStreamserve r.__Init__(self , addr, requestHandler)

# Client is a lot more complicated and feels fragile
from httplib import HTTP, HTTPConnection
class UnixStreamHTTPC onnection(HTTPC onnection):
def connect(self):
self.sock = socket(AF_UNIX, SOCK_STREAM)
self.sock.conne ct(SOCKPATH)

class UnixStreamHTTP( HTTP):
_connection_cla ss = UnixStreamHTTPC onnection

class UnixStreamTrans port(Transport) :
def make_connection (self, host):
return UnixStreamHTTP( SOCKPATH) # overridden, but prevents IndexError

proxy = ServerProxy('ht tp://' + SOCKPATH, transport=UnixS treamTransport( ))
# proxy now works just like any xmlrpclib.Serve rProxy
Jul 18 '05 #4
> Hmm. On inspection, pyro seems to be really heavy, what with its
requirement of a pyro-nameserver, and using TCP as the transport.


The nameserver is purely optional. Regarding the overhead of transport -
well, I didn't check pyro on that, but corba is 10-100 times faster over
the network than soap/xmlrpc. So while the local loopback _might_ be slower
(I'm not even sure about that) than the unix socket, marshalling data as
xml has its own cost overhead.
--
Regards,

Diez B. Roggisch
Jul 18 '05 #5
Diez B. Roggisch wrote:
... corba is 10-100 times faster over
the network than soap/xmlrpc. ...


I'm not challenging these statistics (because I don't know),
but I would be interested in the source. Are you referring
to the results of an actual benchmark, or something more
subjective?

Steve
Jul 18 '05 #6
Stephen Waterbury wrote:
Diez B. Roggisch wrote:
... corba is 10-100 times faster over
the network than soap/xmlrpc. ...


I'm not challenging these statistics (because I don't know),
but I would be interested in the source. Are you referring
to the results of an actual benchmark, or something more
subjective?


Mainly personal expirience (I run a corba server that has an xmlrpc server
on top to adapt the interface for php, which has limited corba facilities),
but there are benchmarks on this that support my claim:

http://csdl.computer.org/comp/procee...8500084abs.htm
--
Regards,

Diez B. Roggisch
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1821
by: glin | last post by:
Hi I am trying to integrate the xmlrpc server into a class, does anyone know how to get it working? test.html: <html> <head> <title>XMLRPC Test</title> <script src="jsolait/init.js"></script> <script src="jsolait/lib/urllib.js"></script> <script src="jsolait/lib/xml.js"></script>
0
1723
by: Juan Carlos CORUÑA | last post by:
Hello all, I'm trying to create a COM Server with an embedded xmlrpc server. Here is way it must work: - The client application (programmed with a COM capable language) instantiates my COM server (programmed with python). - The COM server must have a connect interface in order to let the client application process the xmlrpc request. -...
42
2543
by: Irmen de Jong | last post by:
Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I need a fast and safe (secure) marshaler. Is xdrlib the only option? I would expect that it is fast and safe because it (the xdr spec) has been around for so long. Or are there better options (perhaps...
1
2784
by: Joxean Koret | last post by:
Hi to all! I'm having troubles to make my XMLRPC application working with non ASCII characters. Example: 1.- In one terminal run the following script: -----------XMLRPC Server-------------
1
3200
by: emielvl | last post by:
Hello, I'm developing a client/server architecture based on the XML-RPC implementation in php4. All works pretty well, except that in the response from the server there is no "Content-Length" in the header. Since the XML-RPC specification requires this header to be present in the server response, some libraries (notably: libxmlrpc++) choke...
4
8181
by: elyob | last post by:
Hi, I've got --with-xmlrpc option in my php.ini and can see on my phpinfo page. Now, how do I include this in some code? So far I've been downloading xmlrpc into a folder and just calling it from there, but if it's already installed what do I change to get this version working? Currently, I am calling ... require("../xmlrpc/lib/xmlrpc.inc");...
3
2832
by: Manuel | last post by:
Hello I need a xmlrpc lib for c++. I know two: xmlrpc++ and xmlrpc-c. But i don't know that it is best for me. I am developing an application in c++. I read that the xmlrpc-c lib is in C and wrap the functions to use in c++. Well, i think that it is more difficult to use than xmlrpc++ that it is made in c++. The trouble is that the...
0
2738
by: Benjamin Grieshaber | last post by:
Hi, I´m on SuSE 9.3 with xmlrpc-c and xmlrpc-c-devel installed (ver. 0.9.10) I tried to compile php with xmlrpc support and got the following errors: ext/xmlrpc/.libs/xmlrpc-epi-php.o(.text+0x359): In function `set_zval_xmlrpc_type': /php-5.2.5/ext/xmlrpc/xmlrpc-epi-php.c:1313: undefined reference to...
4
3928
by: care02 | last post by:
I have implemented a simple Python XMLRPC server and need to call it from a C/C++ client. What is the simplest way to do this? I need to pass numerical arrays from C/C++ to Python. Yours, Carl
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.