473,888 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4355
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.blogs pot.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.blogs pot.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
5930
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 disable Ctrl-Alt-Delete. It seems there seems to be only one real way I know about: Write a replacement Gina Driver to eat the keyboard events I dont want. Does anyone have a good template for this in Visual Basic .Net?
2
1543
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 problem is after i had the IRC client functionality and Windows sockets it DID NOT work.
4
2237
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 process? 2. What information contained in sn key. I gone through that it is having public key. How it is using this key to intract with client. 3. When we have to run gacutil.exe file. Whenever we
1
20419
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 an "internal" server and simply relay all information back and forth (when the client sends something, my app sends that to the server, when server sends something, my app sends that to the client). While what I have right DOES work, the...
2
1237
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 the server's response GO back to all the clients on that port, or just to the one who sent the request? In other words: Client One - Request Data From Server (It takes a few seconds for the server
7
2689
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. So, I used a packet sniffer and saw the protocol (TCP), the port, IP address, etc. All is good. I tried 2 different versions of .NET code to duplicate the requests to the remote server. Again, I used the packet sniffer and my packets seemed...
0
1158
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. --------------------------------------------------------------------------------------------- What new functionality is added to this feature in Windows XP Service Pack 2? Restricted traffic over raw sockets Detailed description
6
38547
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 through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
6
4936
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
9961
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10778
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10886
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3252
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.