473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Basic question about sockets and security

Hi all,
I'm just starting out in sockets/network programming, and I have a very
basic question...what are the 'security' implications of opening up a
socket? For example, suppose I've written a simple chat server and chat
client. The server opens a socket, listens on a port, and accepts incoming
connections. The clients open a socket and connect to the server. If the
server receives a message from a client, it sends that message out to every
client. When a client receives a message, it places it in a text widget.
So...are there inherent dangers in doing this? I have no real security
concern in the actual application, but can an open socket somehow allow
someone access to the rest of the computer? Is the 'security' of the socket
handled at the OS level (or within the socket module)?
I realize this isn't necessarily a Python question, but I wrote my
application in Python and I'm not sure where to start. I'll repost this
elsewhere if someone points me towards a more relevant group.
Thanks,
Dave
May 2 '07 #1
2 4308
Dave Dean wrote:
Hi all,
I'm just starting out in sockets/network programming, and I have a very
basic question...what are the 'security' implications of opening up a
socket? For example, suppose I've written a simple chat server and chat
client. The server opens a socket, listens on a port, and accepts incoming
connections. The clients open a socket and connect to the server. If the
server receives a message from a client, it sends that message out to every
client. When a client receives a message, it places it in a text widget.
So...are there inherent dangers in doing this? I have no real security
concern in the actual application, but can an open socket somehow allow
someone access to the rest of the computer? Is the 'security' of the socket
handled at the OS level (or within the socket module)?
I realize this isn't necessarily a Python question, but I wrote my
application in Python and I'm not sure where to start. I'll repost this
elsewhere if someone points me towards a more relevant group.
It's something that all Python network newbies would like to know about
(and OUGHT to know about), so it's a valid question.

Essentially all opening a server socket does is to allow anyone who can
connect to send data to your process. The difficulties usually begin
when your process doesn't handle it in a secure way.

Typically in a language like C this will involve failing to check its
length, thereby allowing a malicious user to send an over-length input
and (since local variables in CC are held on the stack) overwriting
crucial data like function return addresses.

Such exploits can be used to inject code into your process and have it
run. Since server processes often run at a high level of privilege, so
does the exploit code.

Another way you can introduce vulnerabilities into your code is to craft
inputs that, when incorporated into system calls, maliciously change the
intent of your code. So suppose you had a command to allow a user to
ping another computer, you might do (something like)

os.system("ping "+address)

where the address is what the user types in. However, if the user types
in something like

192.168.12.13 ; rm /etc/passwd

then your call becomes

os.system("ping 192.168.12.13; rm /etc/passwd")

and executes two shell statements, the second of which is rather
destructive.

So, as long as you aren't passing any user data to the operating system
in any way shape or form you are probably in reasonably good shape. But
this is easier to do than you might imagine, and you always need to ask
yourself what the downside potential of malicious inputs might be.

Python's libraries are well written by and large, and the language
itself checks the bounds of all data structure accesses, making buffer
overflow exploits of the type I described much less of a risk, but the
OS vulnerabilities still remain for you to avoid by careful coding.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------

May 7 '07 #2
Dave Dean wrote:
[socket security inquiry]

One further point: everything I wrote for server sockets applies to
client sockets too if there's a possibility they are interacting with a
server that's been maliciously coded, or compromised in some way by an
attacker.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------

May 7 '07 #3

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

Similar topics

5
by: Greg | last post by:
I am developing an application where I need to secure a workstation for periods of time. I can use BlockInput to stop users from task switching or messing with the keyboard, but I would like to...
2
by: roni | last post by:
hi. i want to build USER CONTROL that will be used in WEB PAGE. to build user control and use in web page,I KNOW . i did user control with textbox and lable for example and it works. the...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
1
by: Adam Clauss | last post by:
I am (attempting) to move an existing socket application to use raw sockets. Right now, my application is essentially a port forwarder. Upon receiving a connection, it will open a connection to...
2
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does...
7
by: D. Patrick | last post by:
I need to duplicate the functionality of a java applet, and how it connects to a remote server. But, I don't have the protocol information or the java source code which was written years ago. ...
0
by: richard.charts | last post by:
Well, unfortunately, I couldn't get any answer on the msdn forums, so I'll give it a shot here. Real question at the bottom....
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
6
by: 7stud | last post by:
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv textport = sys.argv s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.