• By Brad Conte, November 13, 2009
• Post Categories:
Computers & Tech,
Security
[Update: Jan. 24, 2010] The DNS leaking problem described in this article applied to FoxyProxy v2.14. On Jan. 12, FoxyProxy
v2.17 fixed the problem.
FoxyProxy is a popular
Firefox extension that enables users to, setup, easily manage, and quickly switch between multiple proxy configurations. One of the most common uses of a proxy server is for security/privacy. By establishing an encrypted connection (usually via SSH) with a proxy server on a trusted network, you can have your web traffic go through an encrypted “pipe” to that server and have that server send and receive web requests on your behalf, relaying data to and from you only through that pipe. By doing this you eliminate the risk that someone on your current network could see your HTTP traffic. Maybe you don’t trust other clients on the network, maybe you don’t trust the gateway, it doesn’t matter — your HTTP(S) traffic is encrypted and shielded from prying eyes. (Readers unfamiliar with the concept of using HTTP proxies through SSH tunnels are encouraged to research the matter, there are many well-written tutorials available.)
There are many other popular uses of proxy servers, but the application of encrypted web traffic is of concern in this case for the following reason: A key problem that arises when using web proxy servers is the issue of handling DNS requests. DNS does not go through the HTTP protocol, so even if HTTP is being forwarded to a proxy the DNS requests may not be. If DNS requests are sent out over the network like normal then eavesdroppers can still read them. So although the actual traffic may be encrypted, the DNS queries behave normally and may cause the same problems that using an encrypted tunnel was designed to avoid in the first place. A situation in which HTTP traffic is encrypted but DNS is not is referred to as “DNS leaking”. When using a proxy for the benefit of security or privacy, DNS leaking may be just as bad as non-encrypted traffic.
Solving the DNS leaking problem is simple. One type of proxy, SOCKS5, can forward DNS requests as well as HTTP(S) data. A user simply needs to tell their browser to use the SOCKS5 proxy for both HTTP(S) and DNS and then both will be routed through the encrypted stream, allowing the user to surf the web with greatly strengthened security and privacy.
However, Firefox users who use FoxyProxy at the moment will encounter a problem when using DNS forwarding to a SOCKS5 proxy. When using FoxyProxy, DNS leaking occurs even when it is configured not to, which has made many users very upset. Initially many people thought the problem was with Firefox 3.5, but others confirmed it was only present with FoxyProxy installed. Unfortunately, however, not everyone is convinced that this is FoxyProxy-related behavior and I have not found anyone who has presented a solution yet. I plan to do both.
This is the basic setup for my tests:
Using this I was able to monitor all DNS requests while I experimented with Firefox and FoxyProxy using a SOCKS5 proxy. I did a base test with no proxy configuration, a test using Firefox’s included proxy management, and a test using Foxyproxy for proxy management.
Using no proxy
Starting with a default configuration (SSH SOCKS connection established but no proxy settings configured to use it) I visited several websites such as google.com, yahoo.com, and schneier.com. This was the simple base test.
I checked
showmyip.com to get my IP address.
The relevant about:config settings:
network.proxy.socks “”
network.proxy.socks_port 0
network.proxy.socks_remote_dns false
network.proxy.type 0
Via Wireshark I watched as the websites generated normal DNS requests over the standard network.
Using Firefox to configure proxy settings
I restarted Firefox to avoid any cached DNS entries. Then, without FoxyProxy installed, I setup my SOCKS5 proxy. (Note that FoxyProxy replaces the standard Firefox proxy editor, so it is impossible to not use FoxyProxy when it is installed.)
Under Firefox’s Preferences/Tools (depending on your operating system) I went to the “Advanced” tab, “Network” sub-tab, and opened “Settings”. I chose “Manual proxy configuration” and entered “localhost” for the SOCKS Host and “8080″ for the port.
Unfortunately, Firefox v3.5 does not support a GUI method of enabling DNS SOCKS5 proxying, so I had to manually go to about:config and enable it by setting
network.proxy.socks_remote_dns to “true”.
I checked showmyip.com to ensure that my IP address displayed as coming from the server and not my client. It did show as coming from the server, so Firefox was using the proxy.
The final about:config settings were:
network.proxy.socks localhost
network.proxy.socks_port 8080
network.proxy.socks_remote_dns true
network.proxy.type 1
I visited the same websites. Via Wireshark, I did
not see any DNS requests sent over the standard network. Firefox channeled both the HTTP and DNS data through the SSH tunnel perfectly.
Using FoxyProxy to configure proxy settings
I reset all the about:config settings back to their defaults. Then I installed
FoxyProxy Standard v2.14. I went to FoxyProxy’s options and, under the “Proxies” tab, created a new proxy entry whch I named “SSH SOCKS5″. I set it to connect to “localhost” on port 8080. As well, I check-marked the “SOCKS proxy?” box and selected “SOCKS v5″. I went to the “Global Options” tab and checked the box “Use SOCKS proxy for DNS lookups”. To let this take effect, I had to restart Firefox.
When Firefox had restarted, I went to the Tools > FoxyProxy menu and selected to “Use proxy SSH SOCKS5 for all URLS”. I checked
showmyip.com to ensure that my IP address displayed as coming from the server and not my client. It did show as coming from the server, so Firefox was using the proxy.
I checked about:config:
network.proxy.socks “”
network.proxy.socks_port 0
network.proxy.socks_remote_dns false
network.proxy.type 0
The configuration was the same as the default, so apparently FoxyProxy does not adjust about:config to do its work.
Watching the DNS requests via Wireshark, I watched as
all the website visits generated DNS requests over the normal network. Complete and thorough DNS leaking. And I would like to emphasize that I had selected “Use SOCKS proxy for DNS lookups”, which is FoxyProxy’s option to address the DNS leaking issue.
Fixing DNS leaking
There was no question about it, FoxyProxy caused the DNS leaking in my test. I wanted to solve the problem so I fiddled with about:config.
In about:config I manually set
network.proxy.type to 1. I verified my IP address was from the server via showmyip.com.
The new about:config:
network.proxy.socks
network.proxy.socks_port 0
network.proxy.socks_remote_dns false
network.proxy.type 1
I watched for DNS requests again via Wireshark. I saw
none. It seemed that just manually setting
network.proxy.type to 1 fixed the FoxyProxy DNS leaking problem.
I also tried other about:config settings, such as manually changing
network.proxy.socks_remote_dns to “true”, but that didn’t work. The above was the only change in about:config that I found that fixed the problem.
Summary
I repeated the results above three times in different orders on different computers on both Linux and Windows to ensure I made no configuration mistakes and to ensure that the behavior was consistent and cross-platform. All the tests yielded the same results. Here is the final summary:
- Firefox v3.5 does not suffer from DNS leaking by itself.
- DNS leaking occurs when FoxyProxy is managing the proxies.
- FoxyProxy does not suffer from DNS leaking when network.proxy.type is manually set to 1.
It is obvious that FoxyProxy does not adjust about:config in order to configure proxy settings, but I do not know why. Many Firefox extensions adjust about:config in order to accomplish their goals and I know of no reason they should not. It’s possible that FoxyProxy has not had a need to do so before, but in light of this serious problem that may need to change. The quickest/simplest solution for FoxyProxy may to set
network.proxy.type to 1 if the currently enabled proxy is SOCKS5 and if the global options for FoxyProxy (or the about:config for Firefox) are set to enable DNS forwarding.
However, although this seems to indicate that FoxyProxy has made a mistake, I don’t know that FoxyProxy is the party at fault. Clearly FoxyProxy does not have to alter about:config in order to change the other proxy settings, so why must
network.proxy.type be set in about:config in order for DNS forwarding to work? Note that
network.proxy.type isn’t related to DNS forwarding, it just specifies which type of proxy is enabled. For all I know someone implemented a hack in Firefox that checks about:config when it shouldn’t. Of course, I don’t know that and I don’t know if this is expected behavior from Firefox or not. It could be that FoxyProxy isn’t setting whatever hidden configuration for DNS forwarding that exists on the same plane as the other invisible proxy settings it uses. Or maybe FoxyProxy is relying on an unreliable hack in order to avoid changing about:config. I don’t know about any of that. What I do know is that Firefox by itself does not have this DNS leaking problem, FoxyProxy does, and a simple solution exists.
Again, I am certainly not the first person to note this problem, but a) I have seen many people blame Firefox for this bug, and b) I have not yet seen anyone else mention the solution that I noted above.
I leave it to someone with more time and knowledge about these software projects to determine which project should have which bug report filed. This needs to be fixed permanently.
• By Brad Conte, January 11, 2009
• Post Categories:
Computers & Tech
The power of Linux lies in the tools it uses. If you spend a lot of time in a terminal, you likely value anything that makes using it smoother. Here are a few tips to help make the terminal experience as smooth as possible. These tips are all shell-independent.
Change directories with the directory stack
The Bash shell (as well as others, like Zsh) have a built-in “back” feature for navigating directories. The built-in “pushd” command will put your current working path at the top of a shell-maintained stack and allow you to change to another directory. To go back to the saved path you can use “popd”.
Example:
user@host : /some/long/path/you/don’t/want/to/retype$ pushd /some/other/path/
/some/long/path/you/don’t/want/to/retype
user@host : /some/other/path/$
[do stuff]
user@host : /some/other/path/$ popd
/some/big/long/directory/you/don’t/want/to/retype
user@host : /some/long/path/you/don’t/want/to/retype$
Since “pushd” stores the directories in a stack, you can push multiple directories onto the stack and later pop them off in the reverse order you pushed them. It’s basically the standard “cd” only with a “back” feature. Speaking of which, the command “$ cd -” will always take you back to the previous directory you were in.
Interact with the X clipboard
Before I discovered “xclip”, one of the most annoying things about being in a terminal was my lack of access to the X clipboard. Most shells (all the ones I’ve come across) have a simple means of pasting text into the terminal, but not all have an elegant means of getting text out of the terminal. Yes, highlight-and-middle-click is often an option, but it’s a) not always feasible, and b) not always convenient. Remember, this is the terminal, you don’t necessarily want to be using your mouse. “xclip” removes the annoyance of using the X clipboard.
xclip can read and store to the clipboard from the standard input. As well, it can output the current contents of the clipboard. Since xclip can manipulate multiple clipboard buffers, the argument “-selection c” must be used to select the standard X clipboard. The “-i” and “-o” arguments tell xclip whether you are inputting or outputting clipboard contents, respectively.
Example:
$ pwd
/some/long/path/you/don’t/want/to/retype
$ ls /some/path | xclip -selection c -i
You may now paste (standard Ctrl-v, or right-click -> paste) the directory listing where ever you choose. Another example:
xclip -selection c -o | cat >> /some/file
This will concatenate the contents of the clipboard to “/some/file”.
If you only use yourself using xclip to manage the X clipboard, you might want to consider aliasing “xclip” to “xclip -selection c” to make it simpler to type. Or you could take it one step further and alias “xcopy” to “xclip -selection c -i” and “xpaste” to “xclip -selection c -o”, or something similar.
Use “head” and “tail” more powerfully
You probably know how to use “head” to extract the first N lines from a file and “tail” to extract the last N lines of a file. While this is useful, it’s often just as useful to extract the complement of those selections, namely, everything except the first N lines or everything except the last N lines.
Thankfully, “head” and “tail” are powerful enough to accommodate those needs. “head” allows you to extract either a finite quantity of text from the top or everything but a finite quantity of text from the bottom, and “tail” allows you to extract a finite quantity of text from the bottom or everything but a finite quantity of text from the top.
• head -n N — by default outputs the first N lines. Using -N outputs all but the last N lines.
• tail -n N — by default outputs the last N lines. Using +N outputs lines starting on the Nth.
Example:
/tmp $ cat example
1
2
3
4
5
/tmp $ head -n 2 example
1
2
/tmp $ tail -n 2 example
4
5
/tmp $ head -n -2 example
1
2
3
/tmp $ tail -n +3 example
3
4
5
Note that tail’s complement mode requires you to specify the first line number to include in the output. Thus if you want all but the top N lines, actually specify N+1.
• By Brad Conte, November 25, 2008
• Post Categories:
My Projects
About
I wrote LoginMSG to address a very simple convenience that I was without in my day-to-day life in Linux, namely, a simple way to leave myself a one-time message for the next time I logged in.
Keeping to-do lists is one thing, but quick “first thing tomorrow” reminders are another. After writing my fair share of such reminders, I got tired of going through post-it notes and decided to write a quick script that would allow me to automatically display myself a message the next time I logged in.
Thus LoginMSG was born. LoginMSG is a simple shell script (less than 50 lines long) that stores a text message and displays it. You can add a message, append to the existing message, remove the message, and view the existing message. When you view the message, a simple, no-frills xmessage box is displayed center-screen with your message, allowing you to read it and then remove it or keep it.
Download
•
LoginMSG v.1 –
Jan 6, 2009
Usage
LoginMSG v.1 – Display yourself a message (the next time X starts)
usage: loginmsg [ options ]
–add MSG : Create a message with contents MSG, or
append MSG to the existing message contents.
Message contents are stored in ~/.loginmsg.
–show : Display the message.
–remove : Remove any existing message.
Place the script somewhere in your $PATH. Add (or append) a message from a terminal using “loginmsg –add”. To display any existing messages when you login, have your desktop environment run “loginmsg –show” when you log in. LoginMSG does not have a feature to make itself automatically start when a user logs in — you will have to see to that manually. There are many ways to do this. For example, in Gnome you could add it to the “Session” list in System -> Preferences -> Session. In Openbox, you could add it to ~/.config/openbox/autostart.sh. Reference the help pages for your specific desktop environment.
• By Brad Conte, September 27, 2008
• Post Categories:
My Projects
I’m a user of
ArchLinux, a lightweight and flexible Linux distribution that tries to Keep It Simple.
There are thousands of packages officially maintained in Arch’s
package repositories. However, to ensure the robustness and completeness of available packages, a supplementary user-administrated repository exists, where users can create and maintain their own packages. This is called the
Arch User Repository. The AUR allows users to add lesser-known packages that are not widely used enough to warrant maintenance time from an official developer, create spin-off packages of packages in the official repositories, contribute their own scripts, etc.
I’ve made a few contributions to the AUR. To see them, I refer you to:
•
My AUR profile
•
My AUR List of Packages
• By Brad Conte, September 5, 2008
• Post Categories:
Computers & Tech
Bash is a Unix shell of many features. One of those features, which is both useful and potentially annoying, is the path hash table.
The environment variable we are probably most familiar with is PATH — it contains all the paths that should be searched when we specify an executable to run. Bash starts with the first path specified in PATH and looks to see if there is an executable present, if there is not it checks the second directory, and so on until it either finds an executable with the specified name or it runs out of paths to search.
The path of an executable practically never changes. “ls” is always in the same place, as is “cat”, and every other executable you might have. Thus, to save time, the first time Bash executes an executable it saves the path it finds the executable in, this way Bash can avoid searching for the executable again. The first time you execute “ls”, Bash has to search for it. The second through bajillionth times you execute it, Bash will just look up the full path from the table — much more efficient. It is important to note that every instance of bash maintains its own path hash table — thus if you have multiple terminals open they will not share path tables.
However, if the actual desired path of an executable changes, problems can arise. By default, Bash will not look for an executable again. If an executable changes paths, Bash will not find it. If an executable is duplicated to a new path, Bash will execute the original executable even if the new one is in a path of higher priority (namely, listed first in PATH). As can be imagined, this can cause quite a headache in these rare scenarios if one is unfamiliar with Bash path hashing. If you create a script, execute it, then edit it and copy it somewhere else (say from your personal “bin” to a global “bin”), the old version will still execute. If you simply move an executable between paths, bash will not find the new executable despite the fact that it seemingly should. Observe the following example, in which I create “myscript” in my home bin, run it, copy it to a global bin, run “myscript” again, and execute the one in my home bin again.

(This image can suffice stand-alone — feel free to redistribute it.)
Thankfully, however, the hash table is easily manipulated — by the builtin shell command “hash” no less. There are four switches that are likely of the most interest to you:
- “-d [name]” will delete a specific entry from the table
- “-r” will remove all entries from the table
- “-t [name]” will list the save path for the given executable name
- “-l” will list all existing executable -> path entries in the table
Using this tool you can view existing hashes and remove old stale ones as you see fit. To solve an out-of-date path hash problem, simple removing it will suffice. The next time the command is run the path hash will be re-updated. For more details, I refer you to the following key excerpts from the Bash man page:
If the name is neither a shell function nor a builtin, and contains no
slashes, bash searches each element of the PATH for a directory con-
taining an executable file by that name. Bash uses a hash table to
remember the full pathnames of executable files (see hash under SHELL
BUILTIN COMMANDS below). A full search of the directories in PATH is
performed only if the command is not found in the hash table. If the
search is unsuccessful, the shell prints an error message and returns
an exit status of 127.
[...]
hash [-lr] [-p filename] [-dt] [name]
For each name, the full file name of the command is determined
by searching the directories in $PATH and remembered. If the -p
option is supplied, no path search is performed, and filename is
used as the full file name of the command. The -r option causes
the shell to forget all remembered locations. The -d option
causes the shell to forget the remembered location of each name.
If the -t option is supplied, the full pathname to which each
name corresponds is printed. If multiple name arguments are
supplied with -t, the name is printed before the hashed full
pathname. The -l option causes output to be displayed in a for-
mat that may be reused as input. If no arguments are given, or
if only -l is supplied, information about remembered commands is
printed. The return status is true unless a name is not found
or an invalid option is supplied.
• By Brad Conte, July 16, 2008
• Post Categories:
Computers & Tech
The GNU/Linux project has begot the most versatile operating system ever. It’s free, open source and designed to be modified and built upon by its users. The heart of the Linux philosophy is the concept of choice. Linux is about providing its users with the freedom to choose what they want to do and how they want to do it. Because both Linux and the software developed for it is so versatile, there exist
hundreds of
Linux
distributions, each one being nothing more than a different collection of software and configurations running on top of the Linux kernel.
Because of the number of Linux distributions and the degree to which their styles/configurations can vary, a given user usually has the ability to choose a distribution closely suited to their specific needs. To aid the ever-prevalent distro-seeker, many Linux users have sought to provide written reviews of various Linux distros. Unfortunately, many reviews fall short. With the increasing population of Linux users, and the increasing number of Linux distributions, there has been a notable increase in unhelpful reviews.
Which leads to the point of this article, namely, how to review a Linux distro. The idea of reviewing a Linux distro is to inform the reader as to how the specific Linux distro in question is different from the other Linux distros. To do this, a reviewer must provide an analysis of the software and configurations that set the disto in question apart from other distros, putting solid emphasis on the big differences, less emphasis on the minor differences, and no attention to the things that are inherent in all Linux distributions. (If you are writing to inform the writer about Linux, you should do that instead, rather than pretend you are reviewing any specific distro.) This basic principle holds for almost any review of any product. For example, movie reviews tell you why one movie, a four-star action flick, is different than another movie, a two-star romantic comedy. The movie reviewer doesn’t spend time explaining the concepts of cut-scenes and character development, it merely explains the aspects of a movie that make it unique.
This article is aimed at the potential Linux distro review writer. It is split into two main sections: things one should review, and things one should not review. Most of the points have sample topics for that point, some of the points and sample topics are more advanced/technical, some are less so. No good review must cover every point and sample topic in this article, this is just a broad list of good ideas. Suit your information for the knowledge level of your target audience.
Here’s a list of things that make for a
good review. This is not an exhaustive list, but it covers a lot of ground.
The above topics cover a lot of ground. Obviously not every detail need be included in a good review, but many of these points are very critical to how the distro works and failure to address a significant number of them will result in an incomplete review of the distro. If there seem to be too many points to address, remember that you’re writing a technical review, not a grand work of fiction. Wordiness can usually be eliminated. If you know what you’re talking about and put some thought into what you write, you can cram a lot of information into three sentences.
One key to remember is that that not all of the information may seem important to you, the author of the review, but it is what separates one distribution from another. Obviously the information has to be appropriate for the audience you are writing for; that is a decision faced by every technical writer.
If you feel unable to address many of these topics in your review then you probably have no business reviewing the distro and are not as familiar with it as you should be. Many people want to pop in a CD, install the distro, play with it for 40 minutes, and then write a review about it. Unless you did your research beforehand and you made
very good use of those 40 minutes, you’re not qualified to offer a review. Spend your time learning more about the distro rather than writing about what you do know.
Remember, your goal, as a reviewer, is simple: Review things from the perspective of the average user you are writing for. Don’t go into pain-staking detail unless you’re aiming to provide an in-depth guide, minor details/quirks are often best left for their own special article and are of interest to few readers. Don’t waste time on things that were (likely) very unique to your experience, because almost no one else cares.
Even though this article was somewhat long, your distro review doesn’t have to be. (If it is very long, it’s probably more of a guide than a review. Keep manuals as manuals, and reviews as reviews.) If you have an actual depth of information to convey, you can say a lot by using well-crafted sentences.