Opensource firmware for WiFi router I have two routers from D-link which are DIR615 and 2750U. Both of the firmware are upgraded to latest versions. They don't have bandwidth control. Found there are lots of opensource firmware available which has that feature. Like OpenErt, DD-Wrt, etc. Are they safe to use? in the perspective of getting hacked, stealing data, etc?

Thanks,
Debraj

Open source firmware, namely OpenWRT and dd-wrt are supposed to be more secure and "open" than the stock firmware. After all, they are based in open source. And poised to over time, having more regular updates than the stock firmware. They also have a very strong and active community.

They are supposed to improve you security outlook, and you can disable/customise much more things than in the original firmware.

They often also bring more functionalities than the original firmware; on the other hand they can miss others.

dd-wrt is strongly oriented to more unexperienced users, openwrt to die hard system administrators and developers. With openwrt, you manage it pretty much like another Linux distribution system; on the other hand you can manage dd-wrt even in your iphone with a nice interface. However, openwrt already gets a nice web interface, and if it has a far much more recent version than dd-wrt, I would advise considering it.

I myself have a TP-Link with openWRT, and have customised it a lot in the command line. The installation was painless. OpenWrt allows to use VLANs in the switch chip at will, which was not certainly the case with the default stock firmware, however does not allows to handle NAT in some accelerator chip, which makes absolutely no difference to me as I am doing NAT in another router.

Nevertheless, it would not make much of a difference even doing NAT there. Openwrt also allows me to install software for debugging problems more effectively, and eventually using a more interesting 802.1X setup than the default hardware, which has some limitations handling 802.1X.

On the wifi side, the protocols attacks are pretty much the same. On my model default firmware and in openwrt, you can create an isolated guest network and give a different password to visitors, your mileage may vary.

I myself trust more openWRT than the stock firmware that came with the TP-Link. The security records of appliance vendors is not one of the brightest - and backdoors are aplenty - ; often they only care about sales, and stop supporting updates after a very short while.

As a last side note, my own OpenWRT administration IP is in a VLAN that is not allowed to talk with the Internet.

disclaimer: I am not saying I do believe it is completely secure, however I am inclined to trust it more than the firmware from the vendor.


amd64 safer than 686-pae? Apart from stronger ALSR entropy...

Is a system using amd64 any safer than 686-pae?

What are the advantages, if any?

In general, yes, using 64-bit architectures is a bit safer.

ASLR (Address Space Layout Randomization) is a lot more effective on 64-bit architectures.  On 32-bit architectures, ASLR is not very effective.  On 32-bit architectures, it's only possible to introduce a half a dozen or a dozen or so bits of randomness into the address space layout.  This means that an attacker can defeat ASLR by simply trying many times (a few hundred or a few thousand times).

ASLR makes it harder for an attacker to exploit buffer overrun vulnerabilities, so this difference between 32-bit and 64-bit architectures has some relevance to system security.

Apart from its effects on ASLR, I'm not aware of any security benefits of a 64-bit architecture over a 32-bit architecture.


How to root a virtual device in android-sdk? I was amused to see no one have ever asked such a question here before. After a little research in google I found only a few links to root a device in avd. Somewhere I also read that the sdk is already rooted and you just want to install an application which allows other applications to launch as root (am not sure about this).

The reason why I asked this question here in information security is because rooted devices are a must for Penetration testing an android app. So what I am looking for is a step by step tutorial to root a virtual device in my sdk. I have already created a device with android 2.3. Thanks in advance.

In the emulator which you run as part of Android SDK, the adb has root permissions. That is, it can run with UID as 0. Check it with, adb shell id or whoami. If it is not root, run su in the shell which will give you root access.
In some custom images like Lineage you can start adb with su permissions by using adb root.


Is my RSA signed data secure? So with all of the FUDD (fear/uncertainty/doubt/disinformation) going around about RSA in light of Snowden leaks and other discoveries about backdoors into PRNG, I'm uncertain what this means to me...

I'm currently working with many systems that use RSA to digitally sign things … license files, tokens, etc.

Assuming I've followed all best practices set forth for RSA digital signatures, are those now "insecure" if the right (or wrong) people get ahold of them? Because of these "backdoors" to PRNG, can someone effectively "divine" the private key from the data and signature they have and then create their own signed data and fool my system?

(x-post from: https://softwareengineering.stackexchange.com/questions/214625/is-my-rsa-signed-data-secure)

All the recent fuss is not at all about RSA. It is about Dual_EC_DRBG, a PRNG which has no relation whatsoever with RSA.

Some wild speculation has been made about other usages of elliptic curves, for other algorithms, which again have no relation with RSA, except that some EC-based algorithm may be used as replacements for RSA.

Now there is a relation not with RSA, the algorithm, but with RSA, the company, which edits a number of cryptography solutions, including one, called BSAFE, which implements both RSA (the algorithm)(actually the algorithmS, since there are RSA signature and RSA encryption, which are not the same kind of thing), and the Dual_EC_DRBG PRNG. Any software which was using BSAFE for random numbers may be at risk, depending on what kind of randomness they needed.

It so happens that "normal" RSA signatures (technically called RSASSA-PKCS1-v1_5, or "PKCS#1 v1.5") are deterministic: they don't use randomness at all. In particular, they cannot be put at risk by flawed randomness.

The newer "PSS" padding scheme for RSA uses random numbers, but not in a way which is critical to security. As PKCS#1 puts it:

  RSASSA-PSS is different from other RSA-based signature schemes in
     that it is probabilistic rather than deterministic, incorporating a
     randomly generated salt value.  The salt value enhances the security
     of the scheme by affording a "tighter" security proof than
     deterministic alternatives such as Full Domain Hashing (FDH); see [4]
     for discussion.  However, the randomness is not critical to security.
     In situations where random generation is not possible, a fixed value
     or a sequence number could be employed instead, with the resulting
     provable security similar to that of FDH [12].

(emphasis is mine)


Can I detect when a file is copied on Windows? Can I detect when a file is copied on Windows? Will it create an event in the Windows log? Or can I not? I know you can detect when a file is created due to the file pointers and stuff, but can you detect a file being copied?

Copying is just reading a file's contents and writing them somewhere else. If a user can read a file, they can copy its contents to somewhere where they have write access.

On Windows, there are copy hooks that you could use to log or block the operation, but those only apply to the shell (i.e. Explorer). Using the command prompt would bypass such hooks.

If you want to log file access, you should set up auditing. Basically, you'll need to change the SACL on the file(s) in question to log reads (use the Auditing tab of the advanced security dialog) and also change the system audit policy to record object access. To log the creation of the new file, you'll need to audit Create files / write data in the directory that will receive the copy.

It will still be very difficult to correlate a read operation with the writing of a copy if the user is even a little clever. They could read the contents into memory and wait for a while before writing it out; they could compress or encipher the data to make the copy not be the same on-disk; they could send the file over the Internet to avoid writing any new files at all. You can't really distinguish a pure read from the first part of a copy.


Do you need to encrypt session data? I came across a session management class in PHP which encrypts session data in the session storage folder (i.e., /tmp) and can be decrypted later in your script using a key. I was wondering if it's really needed? If you already doing some session hijacking prevention like this (simplified) example:

session_start();

if (isset($_SESSION['fingerprint']))
    if ($_SESSION['fingerprint'] != md5($_SERVER['HTTP_USER_AGENT'].'SECRETSALT'))
        exit; // prompt for password
else
    $_SESSION['fingerprint'] = md5($_SERVER['HTTP_USER_AGENT'].'SECRETSALT');

Do you still need to encrypt your session data? Or is encryption only needed if you are storing sensitive info via sessions (e.g., personal info, cc number, credentials) ?

Moreover, if you are validating whether a user is logged-in or not in a simple way like this:

// login.php

if ($_POST['password'] == $db_password)
{
    $_SESSION['logged_in'] = true;
    redirect_to_protected_area();
}
else
    // show login again

// protected_area.php

if (!isset($_SESSION['logged_in']) OR !$_SESSION['logged_in'])
    exit; // prompt for password
else
    // show protected area

What damage can be done if session data is unencrypted and a hacker saw the data in plain sight (i.e., the md5 hash of the fingerprint and the logged_in = true). Can he actually log himself in or he must first "crack" the md5?

Note: md5 was used to simplify example, a much better hashing algo is used in real life.

Encrypting your session data in PHP is a bit like locking your car and leaving your keys on the roof. Consider the threat scenarios that apply:

An attacker gains some remote access to the server and attempts to read the session data files.
An attacker steals the server's entire hard disk from the datacenter. This could be through physical theft or through accessing a virtual hard disk file in a virtualised environment.

In the first scenario, the attacker needs to gain access to the server, then either privilege escalate to root or impersonate the user that owns the session data directory (e.g. www-data for Apache, nobody for nginx). These directories have access controls applied (usually 0600 permissions bits) that prevent users other than the owner from accessing the data.

If an attacker already has access to the server and can impersonate the user that the web server daemon is running under, then they can by definition access all of the data that the web server process can access, meaning that they by definition would have access to any encryption keys that the web server or the code running under it might be using (with the exception of a HSM, although that it isn't a reasonable assumption that one would be in use here).

This means that if the attacker can read the session data files, they can also read the encryption keys, which means they can decrypt the session data. The encryption ends up being obfuscation at best.

In the second scenario, the same issue applies: if the key is on the hard disk along with the session data, an attacker can simply read the keys and decrypt the session data. The way to resolve this problem is by encrypting the session data in such a way that the keys are not stored on disk, and the correct approach is to use full-disk encryption (FDE) and manually enter the password at boot using out-of-band management (e.g. iLO, DRAC, remote KVM, etc.) so that the entire hard disk is encrypted in such a way that does not allow an attacker to gain access to any data on the disk if it is stolen.

However, even in this scenario, it may turn out that FDE isn't that much of a security gain in terms of protecting session data. The reason is that, on most platforms and configurations, session data is stored in /tmp, which is backed by a tmpfs volume. The whole point of tmpfs is that it is volatile (i.e. the data is lost on reboot) and in most cases the contents are stored in RAM. Data that is not touched for quite some time may be swapped out to disk, which is where FDE does provide a benefit towards securing session data, but the likelihood is that any old sessions will have expired before this happens. That being said, I still recommend the use of FDE on all systems as part of good security practice, because it protects against other types of data theft (e.g. infrastructure credentials, SSL certificate private keys, etc.)

The only situation in which encrypting session data in PHP makes some sense is if you have session data being stored in a database or key-value store. In this scenario you should expect that the session data will likely be nonvolatile (i.e. stored on disk) and that there might be a situation in which an attacker compromises the database (e.g. getting into an overlooked phpMyAdmin instance) but not the filesystem. In such a case the key would be on the filesystem and inaccessible to the attacker. This is, however, an exceedingly rare case.

One other argument I hear a lot is that certain data must be encrypted for compliance reasons, e.g. PAN data under PCI-DSS. The solutions here depend upon the exact system architecture, but generally speaking you fix this by either not storing the data in the session data at all, by encrypting/decrypting the data using an external broker/HSM so that the keys are isolated, or simply with FDE if you only require offline encryption of data at rest.

While I don't generally recommend it for the reasons that are discussed above, if you're set on encrypting session data in PHP for whatever reason, it's actually quite possible to do it within PHP without modifying every use of $_SESSION. You can use the SessionHandler class to override normal handling of sessions. The documentation provides a simple explanation of how you can encrypt session data.

However, you'll need a way of creating and storing the key across the session. Obviously this can't be done through the session manager itself, otherwise you'd be distributing the key with the ciphertext. My suggestion would to be use an in-memory cache, such as APC or memcache, where the key name in the cache is the session ID.


Legitimately using tools like Havij I'm a developer, not a security guru.  My primary focus is ensuring that I'm not introducing security holes through bad programming.  I understand how to code to protect against the OWASP Top 10, as well as other vulnerabilities, but I know enough to know that I don't know enough.  I'd like to add some additional  testing to our process to scan for vulnerabilities throughout the development process.

We already do threat modeling throughout the project, as well as code reviews on all code changes going into production.

Also, as a part of our release process, we have penetration tests ran against our sites in our staging environment before releasing to live, and also in live once it's released.  However, I'm not confident that our penetration testing tools are adequate. Also, the penetration tests are costly, and can only be done every so often.  I'd really like for our team to perform them throughout the entire development process. (It's a lot cheaper to fix holes early on than later on in the project.)

I'm aware of tools like  Havij that are used by cybercriminals, and I'm aware of how easy they make attacking sites with vulnerabilities for even non-technical people.  I'd love to be able to use the same tools to test our own web sited in our test, then staging, then production environment.  (Why should the bad guys have all the good tools?) But I'm not willing to go to the "shady" sites or newsgroups do download the tools.  I wouldn't even know where to look.  Even if I did know where to look, our network Admins would never allow us to get those tools from an untrusted source.

Is there a legitimate, trusted place where such tools can be downloaded or purchased for such white-hat purposes?  I'm perfectly willing to try to get upper management to pay for membership in white hat groups that might provide these tools, and even better, training, so I'm not necessarily looking for free.  I'm just looking for legal and legitimate sources.

I'd like to point you to open source tools that we use in pen-testing web applications:

Arachni, already mentioned in a previous answer.
w3af, one of the most famous free open source scanners. This one is written in python and have a consistent UI (GUI and CLI). The project is sponsored by Rapid7, owners of Metasploit and NeXpose
Skipfish, a fire and forget command line scanner which excels at crawling and forced browsing, produces fancy HTML reports
OWASP Zed Attack Proxy, the defacto open source web attack proxy. ZAP has an API and integrates code and features of other reference tools like JBroFuzz and DirBuster. It is more suited for semi-automated testing

The following open source tools can help exploiting SQL injection (SQLi) and Cross Site Scripting (XSS) vulnerabilities:

SQLmap: this CLI python tool is ideal to exploit SQL injection flaws, i.e. dump the database, execute SQL commands and even compromise the back-end database's Operating System. It is similar in purpose to Havij and often used in the wild by script kiddies to exploit vulnerable targets
BeEF: the perfect tool to demonstrate the risk of XSS flaws, its new shiny Ruby on Rails web interface allows you to leverage XSS vulnerabilities in order to command victim browsers

There are a lot of commercial tools in the web vulnerability scanning market with prices ranging from a couple hundreds dollars to tens of thousands of dollars. These can get you better results than open source ones and can combine features of open source scanning and exploitation tools. However, you'll always need that chair and blood penetration tester to try and break the logic of the application, something a tool, no matter how much it's worth, can never do.


Is PHP unserialize() exploitable without any magic methods? Say that there was a publicly accessible web page with the following PHP code:

<?php
class NotInteresting
{
    public function noExploits() {
        echo "Whatever.";
    }
}
$unsafe = unserialize($_GET['data']);
$unsafe->noExploits();
?>

The code would expect the data URL parameter to contain a serialized instance of NotInteresting, but of course the data parameter can be manipulated. When unserialize() is used on user supplied data it  often leads to PHP Object Injection.

However, all the examples of PHP Object Injection I have seen so far (1,2,3) have been dangerous for one of two reasons:

There were some exploitable classes with dangerous methods (which were only meant to be called internally) which were leveraged to execute arbitrary code, often the case for a CMS.
The version of PHP was old or outdated and vulnerabilities in the PHP code were exploited.

Given that the PHP version is current - that is, no known vulnerabilities exist in the unserialize() function - and that there are no custom classes defined (just the default ones - Exception, stdClass etc.), is it possible to leverage the above code for a successful attack on a default PHP installation?

Extra info:

As far as I know there are only four exploitable magic methods when constructing an arbitrary class from an unserialize() call: __call(), __wakeup(), __destruct() and __toString():

__wakeup() is called when an object is unserialized.
__call() is called when invoking inaccessible methods (or non-existent ones).
__destruct() is always called after no more references to the object exist.
__toString() is called when an object is treated as a string.

So I wrote a PHP script to quickly generate a list of the classes which contains these magic methods: See here for a pastebin. Some of these look very 'interesting':

The XML classes (could lead to XXE)
The Phar classes

However I am unable so far to construct an attack just with these: I will need someone more experienced to weigh in.

The exploitability of PHP object deserialization depends solely on the available classes (standard classes as well as custom classes), their methods and behavior, and whether it is possible to get one of these exploitable methods triggered.

Note that the exploitable methods may not be that trivial. You may need to create complex object structures using multiple, nested objects to trigger a certain behavior. The number of exploitable methods or their behavior may also change during the time. So even if you may not be able to exploit it today, someone may sometimes be able.


If the attacker knows part of the password but not the length, does that help him in any way? The idea behind this is that if knowing part of the password and not the length is useless, "passwords" can be easily stored in cleartext or paper since you would just add your own n characters identifier and you're "safe".

Password on paper: dad458t5sdADSdkarh

Real password:     dad458t5sdADSdkarh PC

Sub question: Does the position of your own identifier matter?

dad458t5sdADSdkarh PC

dad458t5sPC dADSdkarh

PC dad458t5sdADSdkarh

Sub question #2: Does the length of the personal identifier matter ? Meaning is even 1 character enough (with the baseline being long enough).

This would work as a personal scheme for keeping long passwords on paper - if you work out a system and apply it to your long passwords, but don't tell anyone else, it would be an effective form of security by obscurity. An attacker finding your password list might try the written password, then perhaps if he was very enterprising he might try variations on the written passwords, transpositions, subsequences and so on, but his chances of finding your exact transformation would be very low indeed.

However, an attacker might gain access to your password list and one or more of your actual passwords. The attacker could then observe the relationship between some passwords in your written list and the ones he knows in full, then know exactly how much space he had to bruteforce to get the real passwords from the written ones. In this case your effective password strength is reduced to the strength of your inserted string.

In practice many people use schemes like this for their most important and longest passwords, changing a few characters in an algorithmic but unguessable way then writing down the transformed password. This protects you very well against the common scenario of a house-burglary yielding a piece of paper with 'CitiBank: Login: xxx Password: yyy' written on it, but would be no use at all applied systematically, for all the usual reasons given against security by obscurity.


How to securely store credentials in a bash variables? I need to cache my user credentials in a shell script variable since they are required for multiple requests to a REST-API. It won't be stored in the bash script file itself: user is prompted to enter credentials, and these will be reused along the script execution.

What is the best way to store them so no other non-privileged processes could read those variables?

Storing credentials in plain text is always a tricky case, it depends on case-by-case. The main rule is: never store the password inside the script.

If the script will run only manually (someone executing the script), do not store the password on the script, instead, make the script ask the password every time it's executed.

If the script will run automatically:

Create a specific user for the purpose you need. ensure the user has the minimum permissions as possible. Ensure the user does not have access to any other file and does not have permission to execute anything else other than the script you need.
Create a file containing the password and make the script read from this file. Make sure this password file cannot be read from anyone else.
Is passwords the only way to authenticate? Some applications support private/public keys. If you can, use it. Make sure the private key is secure.
Keep in mind that the chances of those credentials getting compromised are increased just by the fact you have them stored. Having that in mind, plan mitigation actions, for example, ensure the account has the minimum permissions as possible, ensure the account can only log in from a specific server, implement a log monitoring tool (or a SIEM) to get alerted when this account is used.

There's a very good article on the unix stack exchange about this topic, i do recommend you checking it out before implementing any script with passwords.


How do I constrain Windows Smartcards for AD Authentication so that "anyExtendedKeyUsage" is not implied? This document describes how there are 3 ways to constrain a SmartCard certificate

  The Enhanced Key Usage field defines one or more purposes for which
  the public key may be used. RFC 5280 states “in general, [sic] the EKU
  extension will appear only in end entity certificates.” Certification
  authorities’ certificates may contain EKU entries. To allow smart card
  logon within an Active Directory domain the smart card’s chain of
  trust must support the Smart Card Logon (OID 1.3.6.1.4.1.311.20.2.2)
  and Client Authentication (OID 1.3.6.1.5.5.7.3.2) application
  policies. Active Directory smart card logon is supported with the
  following EKU configurations:

  All certificates in the chain of trust do not assert Enhanced Key Usage (except for the end entity certificate) the anyExtendedKeyUsage
  EKU is implied.
  All certificates in the chain of trust do not assert Enhanced Key Usage except for the root trust point certificate. Root trust point
  EKU field asserts Smart Card Logon (OID 1.3.6.1.4.1.311.20.2.2) and
  Client Authentication (OID 1.3.6.1.5.5.7.3.2).
  All certificates in the chain of trust Enhanced Key Usage field assert Smart Card Logon (OID 1.3.6.1.4.1.311.20.2.2) and Client
  Authentication (OID 1.3.6.1.5.5.7.3.2).

  Best practice is for the root trust point certificate not to include
  an Enhanced Key Usage extension. The Federal Common Policy CA
  certificate does not assert an EKU; therefore all application policies
  are implied.

Does this mean I need a dedicated SmartCard PKI in my environment just to constrain Smartcards to authentication?

Is there any way I can have a Root CA defined for all usages + smartcard, and also have a sub-ca dedicated to smartcards so I can trick the AD validation process?

On a general basis, you cannot enforce a constraint such as "should be used only for smartcard logon". This is supposed to be the role of the Extended Key Usage certificate extension; see RFC 5280, section 4.2.1.12:

  If the extension is present, then the certificate MUST only be used
     for one of the purposes indicated.

But this relies on all applications which validate certificates to actually check the EKU and enforce its contents (an application is supposed to check whether the EKU is there and contains its own OID, or the special anyEKU OID; or, at least, the EKU extension should be absent, if the application does not have a specific OID for itself). In practice, applications do not perform such checks. Some applications will do such processing, but you cannot reliably expect all applications to do it, even if you restrict yourself to the pure Microsoft world.

To enforce separation of roles, you really need several PKI (EKU ought to do it, but in practice it does not, which is sad). To some extent, you could make "one" PKI (i.e. one root) and use distinct sub-CA, and you set the subordinate CA themselves as roots (e.g. you would push the sub-CA specific for smartcard issuance as the "root" in the NTAuth store on the Active Directory server). Such sub-CA are root CA in disguise, so you had better handle them as such (e.g. make them long-lived).

In general, enforcing non-usage of issued certificates is a fruitless quest. To cover yourself in a legal way, it suffices to publish a Certification Policy Statement, duly linked to from the Certificate Policies extension in the certificate, where you state in plain words that the certificates are meant for smartcard logon only. It is not needed (and not really possible either with 100% reliability) that you arrange for all other existing software to reject your certificates. Ultimately, any application can validate certificates as it sees fit.


Are new Intel CPUs vulnerable to Meltdown/Spectre? Has Intel released any information about new processors?

According to their advisory a number of processors are susceptible, but it says nothing about when new processors will be fixed. Also Meltdown and Spectre Vulnerabilities has no answers addressing this.

So, from what production date on will/are Intel processors secured against speculative execution attacks?

The processors that were already announced and are about to be launched in the near future will still be vulnerable to both Spectre v2 and Meltdown if patches and/or firmware is not applied correctly. Spectre v1 was not entirely fixed with the latest patches. Most recent products have patches available, although not always functioning very well.
You can easily cross-reference the list of affected products to the soon-to-be-launched ones.

To answer your question directly: Intel plans to fix this on a hardware level in 2018. Intel's CEO stated the following in the earnings call for Q4 2017

  Our near term focus is on delivering high quality mitigations to protect our customers infrastructure from these exploits. We’re working to incorporate silicon-based changed to future products that will directly address the Spectre and Meltdown threats in hardware. And those products will begin appearing later this year.

I don't know what "appearing" means in this context (announcement of new products or release of new products).

Conclusion: throughout 2018 anybody who plans to buy a new processor (or a new laptop/PC with a new processor) will have to take some security measures to secure themselves against Spectre and Meltdown IF the accompanying firmware or the OS has no proper protection against these vulnerabilities.

Edit: After the conversation with R.. I rechecked Intel's official statements. All mitigation attempts and patches only target Meltdown and Spectre v2, because:

  For the bounds check bypass methodthat's Spectre v1, Intel’s mitigation strategy is focused on software modifications.

It remains unclear if this will remain Intel's strategy throughout the next product cycle.


Website fell under the Google filters for inbound links We received a strange message on our support email.

  Message:Website http://fermersovet.ru/ fell under the Google filters
  for inbound links. Google Webmaster shows that your site
  www.mydomain.com has a link to our website. Remove Please link. Thank
  you! Contact Mail:mendrelsdpoeldsa@mail.ru Name:SeoMaster Phone
  Number:694

I looked up this issue and found some links regarding "Smart Spam Bots" - automated bots that might have scraped my Google Analytics ID from my website and are now sending traffic to this website.

My questions:
1. Is this what is happening? How else can I investigate this?
2. Should I be worried about this?
3. If this is not a Smart Spam Bot thing, what other protections can I take?

Just having your GA ID isn't enough to compromise the site. There is the chance that the spambot is sending fake referrer information using your domain name, but that doesn't have anything to do with GA tracking code, and furthermore, it's out of your control even if they do.

If this email didn't come from Google, like @Matthew said, I'd classify it as SPAM and carry on business as usual.


Is Content Security Policy only enforced during initial rendering? Is CSP enforced only during initial rendering, meaning there is no continuous coverage after your document loads? Here is an example of what I'm talking about:

Let's say your page, example.com, has some JS that takes the url parameter name and renders it on the page:

<script nonce="test123">
$(document).ready(function() {
    $("#id").html(nameParameterTakenFromURLWithoutSanitation);
});
</script>

If someone visits example.com?name=<script>alert('XSS');</script>, based on my tests, the script will still execute (popping up the alert) regardless of CSP. Only illegal scripts that exist inside of the initial server response are blocked.

I'm using a "strict" CSP approach using nonces. Here is the policy I'm using:

object-src 'none';
script-src 'nonce-test123' 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;
report-uri http://localhost:8080/csp-collector

Why is the script not blocked?

Introduction

CSP should be enforced by the browser as long as you stay on the page, and not just while it is originally loaded or rendered. Everything else would make it quite toothless.

So the behaviour you are experiencing has nothing to do with when the script is loaded. Instead it is about what loads it. There are two issues.

Problem 1: strict-dynamic

I'll let Mozilla explain it:

  The strict-dynamic directive specifies that the trust explicitly given to a script present in the markup, by accompanying it with a nonce or a hash, shall be propagated to all the scripts loaded by that root script.

So, when you trust a script by giving it a nonce, it can in turn load other scripts. That means that if you have a DOM XSS vulnerability in a script with a nonce, the CSP will not save you. The solution is to remove 'strict-dynamic' (but that will off course be problematic if you rely on this feature).

Problem 2: unsafe-eval

To load the script, you use jQuery .html(). Somewhere deep in the jQuery source code (line 343 to be exact) it makes a call to the good old eval().

So if you run the code

$(".test").html("<scr" + "ipt>alert('XSS');</scr" + "ipt>");

jQuery will for some reason (don't ask me why, I have tried and failed to follow the source code) run the following:

eval("alert('XSS');");

This means that the CSP no longer applies - after all you are not creating a new script tag, you are evaluating a string.

Here the solution is to remove 'unsafe-eval' from the CSP, but that would break jQuery. The solution to that might be to upgrade to jQuery 3, that upon cursory inspection of the source seems to have fixed this.

Conclusion

This means that all code (using jQuery 2) on the form

x.html(unsafeFromURL);

can be vulnerable to XSS even if a CSP is set. I think this is unexpected to a lot of people (it was for me). But it serves as a reminder of another important point: You should not use CSP as your only line of defence against XSS.

Also do note that this is not an issue with how CSP works, but with how jQuery works.


How to execute an exploit without user interaction? Is there an existing exploit, virus or malware that doesn't need any user interaction?
In metasploit for example.
No link to clicked, no pdf to open , no vba or exe to execute by the victim.

Yes, certainly.  Malware that affects network accessible services very rarely require user interaction.   A worm such as SQL Slammer is a prime example, which propagated across the Internet looking for exposed SQL Servers that had a blank password for the sa account.

Client machines may also expose vulnerable services, but even if they don't, they can still be infected without specific user interaction through mechanisms such as drive-by-downloads, where a malicious website or component (like an ad from an infected ad network) uses a vulnerability in a browser or browser plugin to escape the sandbox and silently install.


How are assets assessed for criticality? Following on from the post regarding risks assessments and critical assets, how are assets assessed for criticality be it infrastructure, processes, people (possibly), etc?

If using the security triad of confidentiality, integrity and availability, are these the only factors that define criticality?

How does one calculate the cost of the associated risks? For example, if the business deems a given set of assets as high across the entire triad, how does one determine the impact, costs and risks?

If using the security triad of confidentiality, integrity and
  availability, are these the only factors that define criticality?

While the CIA triad is important to us as security professionals when defining various criteria, the business often defines severity levels based on $$$.

They ask questions (from a business perspective) such as:

What infrastructure / applications do we need in place to accept money
from customers? (think POS systems)
What infrastructure / applications do we need in place to move money? (think wire/ACH systems)
How much money do we lose per day if XYZ application is not available?
Are there operations / processes that can be completed manually (paper, pen) until the systems are back online?

  How does one calculate the cost of the associated risks? For example,
  if the business deems a given set of assets as high across the entire
  triad, how does one determine the impact, costs and risks?

This is where your quantitative and / or qualitative analysis comes into play from a risk perspective.

Below are a few good links that cover the formula in detail:

http://www.pearsonitcertification.com/articles/article.aspx?p=418007&seqNum=4

http://www.sans.edu/research/leadership-laboratory/article/risk-assessment


How to securely send bank details to someone? I have completed my internship and my employer wants me send him my bank account details so that he can transfer me my stipend. How can I securely do this? I have Ubuntu MATE 16.04. My employer is not that tech savvy. He would be fine with emails and password protected zip file/google drive text file but telling him to set up pgp/gpg would be too much.

He would be fine with emails and password protected zip file/google
  drive text file

Firstly, you need to take into consideration the level of security you want vs practicality. In this case, you have mentioned that your employer is comfortable with emails and password protected zips. So, why not do that?

Without being overly complex, how you can do it is:

Type your bank details in a text file and ZIP it up with encryption (you can use AES-256 bit encryption which I believe offers a good enough protection)
Send your password to the ZIP file in a separate email

What I am proposing above protects the transmission of the file. Of course, if you decide that the email service cannot be trusted, there are many ways to make it more secure. You could further:

Encrypt your ZIP file password with another key which is already known to your employer (e.g. your name)
Skip step 2 and call your employer and tell him the password over the phone
Send the password using another email service

To me, even if your bank account details (I supposed that is only your bank account number, bank name and your name) are exposed, there are no severe risks. There is no need to make it overly complex.


Deauth attack without being able to contact the AP In my home pentest lab I though it would be interesting to try this scenario and see if it works:

I have 2 computers and 1 AP, computer A is authenticated to the access point with WPA2 and computer B wants to run a MiTM attack on computer A by making it connect to a fake network. But, computer Bs antenna is not as powerful as computer As so in result computer B can only contact computer A and not the AP thus making a deauth attack though the usual tools useless.

My question is this: Is there a way/utility to deauth a computer without being able to get a frame from the AP?

You only need the BSSID information from the AP to run the aireplay command. Since you said that you are looking for a tool that would let you provide the AP information manually, the command would be like this:

aireplay-ng -0 1 -a <AP BSSID> -c <COMPUTER A> interface

And to get the AP BSSID you could use the airodump-ng, and look at the AP computer A is connected at. (in this case, airodump would get the BSSID based on the computer that is connected to it)


How to implement MySQL query fo RBAC authorization with fine grained business restrictions in role? When implementing an authorization system like RBAC/DAC, or XACML, or the AWS IAM authorization model, I see that I can't totally decouple business logic from authorization when there are fine-grained business restrictions.
We don't use ORM. When composing the query to match the role restriction, we can't make simple queries when we don't know beforehand what the restrictions are.
Example:
    applicant: {
    posting: {
        'read:any': ['*', 'status=active', '!allowed_budget']
    }
},

Today, business wants applicants to have access to status=active, but tomorrow, they may wish to allow if
dept=sales or if date_posting>31/2019. I can't see how to decouple business from authorization rules.
Question 1: How do you code a
SELECT * FROM posting WHERE <place_your_restriction_here>

and you don't know beforehand what the restrictions are? I can only see that I will have to limit the different types of restrictions can be added to the policy and handcraft them one by one.
Question 2: How do you apply this model when fetching lists of records? If I select one record, I can fetch it from DB, match it against policy and allow/deny if XACML says so, but what about listing millions of records? I need a mechanism in place to convert the XACML or RBAC rule to a
SELECT * FROM posting WHERE <user_filter_desired> AND <restrictions_to_apply_from_RBAC_DAC>

All the options I have seen so far are clunky, cumbersome and error prone, specially when you have to add user custom filters with role restrictions.

I am personally a big fan of PostgreSQL row based security which allows you to entirely decouple security from business logic, and is easy to bake into your data access middleware by mapping user's authentication roles to database roles.


ASP.net vs PHP security? I have been told that generally speaking, asp.net web apps tend to be more secure than php, since asp.net has some automatic security measures, for example, by default it doesn't allow remote file inclusions. And when you code in php, you have to take care of those things yourself, so some developers might forget to do that. So my question is, generally speaking, are asp.net web applications more secure than php web apps?

ASP.NET will be more secure than PHP if the developer masters ASP.NET more than PHP. And vice versa.

There are many claims that a lot of features of PHP seem to have been designed by a lemur who had taken acid, leading to a rather tortuous set of features and thus potentially making the task of developing securely rather harder than what it could have otherwise been. However, these details are dwarfed by the skills of developers, or lack thereof. Regardless of the language details, the developer must think of "what could go wrong with the code" and there is no automatic tool which will do the thinking for him.


Example of something that WYSIWYS tries to prevent Wikipedia's article on WYSIWYS is very brief, and says:

  It is relatively easy to change the interpretation of a digital document by implementing changes on the computer system where the document is being processed

I didn't understand this. Can someone show an example? Thanks!

The problem WYSIWYS is trying to prevent is that, when the same file is displayed with different software, or at a different time, or on a different system, etc, it may be displayed differently, even though the binary data is the same.

Imagine someone crafting a web page that displays differently in different browsers. If someone downloaded it as an HTML file and signed it, they would likely assume they had signed exactly the content they saw when they downloaded it, but another user who opens the HTML file in a different browser will see something completely different.

Another example is a document with external references (think images in a web page), even though the user is shown the image before signing the document, what they're really signing is a reference to that image. The user thinks they signed a document that includes the image, but the image being referenced could be modified without invalidating the signature.


What should be a good Open Source dependency scanning frequency? We use Snyk as our open source dependency scanner. We currently scan for vulnerable libraries on every pull request and this causes overhead to our developers. What would be a good open source vulnerability scanning frequency? Should it be weekly, bi-weekly, monthly or continuous?
I am trying to suggest AppSec processes to my team and want to know about industry practices. It would also help if there is a best practices guide out there.

I have never used Snyk, but I've used similar tools.
Running a scan on every pull request seems unnecessary unless that pull request is introducing a change to your dependencies. From my understanding of Snyk's documentation, Snyk scans your manifest files and uploads the dependencies and their versions. As Snyk's database of vulnerabilities is updated, it will alert you of any newly discovered or reported vulnerabilities in your dependencies. Unless you are adding, removing, or updating a dependency, you don't need to rescan.
The first question I would consider is how frequently you are changing your dependencies. If you are regularly changing your dependencies, then you may need to more regularly scan and upload the information from your manifest files to Snyk to make sure the reporting is accurate. However, if you don't change your dependencies often, then there may not be a need to scan as often. If the bottleneck is how long it takes to run a scan and upload the results to Snyk, I'm not sure that this action needs to be taken on every pull request.
If you really wanted the most accurate information, you could introduce some kind of logic to your build server to detect changes to your manifest files and execute a Snyk scan only on pull requests that introduce a change to your manifest file.
The more important thing, in my opinion, is how often you review the results from Snyk. It appears that Snyk does offer push notifications via email, Slack, and other tools when a dependency in your project has a vulnerability. This push notification could be useful to trigger your triage process to determine your exposure to the vulnerability and understand what you need to do to mitigate it.
If you've introduced Snyk to an existing project that has a lot of dependencies, you may be in a mode to play catch-up with updating to patch existing vulnerabilities. Rescanning on every pull request won't really help here, though, unless you're making lots of small pull requests to update each dependency and want Snyk to detect the change. I'm not sure that this is a good approach, though. I'd favor making sure that you have good automated test coverage, updating your dependencies, making any changes to your code to account for the new dependencies, and running both automated and manual testing to confirm that your changes are good. This is a good tactic if you have a large number of very out-of-date dependencies and are pulling major updates in - there could be a lot of work necessary to replace dependencies and it could be worthy of a release of its own.
Having a more robust process to control when dependencies are added and ensuring those dependencies are either free of vulnerabilities, the vulnerabilities are mitigated, or the vulnerability doesn't impact your system is also necessary. This doesn't necessarily require the use of Snyk. There are databases of open-source projects and their vulnerabilities - Snyk maintains one, as does Synopsis. Performing a lightweight vendor assessment to ensure that new dependencies do not introduce new vulnerabilities and you are only introducing dependencies that are well-maintained and offer an acceptable level of support is a good habit to get into.
After all of this, I would favor a nightly or weekly scan. On the more complex systems that I've worked on, running the full suite of all tests (from unit to system acceptance) takes a couple of hours. This testing happens on the development branch on a nightly basis. Integrating an open-source dependency scanner here can make sure that your reporting is always up-to-date, without introducing an extra step into every build. Developers can check in on the build every morning and triage failing tests as well as triage new vulnerabilities in dependencies. This can also be a good time to run static analysis on your code, and if you want to get very secure, deploy to a test environment and run dynamic vulnerability scanners.


Scan interpreted code for long lines to detect code injection? As https://security.stackexchange.com/a/11935/35886 states: the best protection against code injection is to prevent it but often you see posts on SO or here that goes like

  I found "long line of php/perl, etc code" and want to know what it does.

Then I realized that many of those code injections tend to be very long lines of code (beside being encoded and possibly encrypted) to prevent being too obvious at a first glance.

Now I was thinking whether automated scans of any code base for some long lines of code could provide a cheap mechanism to detect code injection blocks in interpreted languages?

A quick search did not reveal any correlation of hits and false positives when scanning for code lines longer than n chars.

I am ware that obfuscated code, but also badly written code would be detected by such a system, but is there a known usage of such a simple technique in any IDS?

For a general hosting provider this might not be practical (or even legal?) to scan all client files for overly long lines as it would required manpower or further risk analysis of all hits and a notification system for the end user. But hosters for blogs etc, which can get some injection by malicious themes or any other type could profit of that. Or am I wrong here?

A lot of anti-malware 'heuristic'-engines do this kind of stuff. They check entropy of chunks of code, or even the entire PE. Lots of malware is obfuscated to exist longer in the wild. The problem with this kind of detection is that is works poorly with smart-er attackers.

eg when I write exploits, I randomize everything keep things small and you will NEVER see me write persistent code to other files. Instead I'll make a reliable exploit and trigger it when I need access to the box.

Thus, yes this works for malware etc, no it won't show human attackers.
However if you can do this on running memory, that will certainly help.


Live OS : secure file deletion In the case of a Live OS (i.e Tails) where filesystems are kept in RAM, is there any difference in the way a file is deleted ?

Specific case considered :

files "1.jpg" and "2.jpg" in a running Live OS
file 1 is deleted the normal way, file 2 is deleted with "shred" command
someone gets full RAM access immediately after (root rights or even physical RAM dump)
can any of these files content be recovered ?

I would like to know if there is any need to use a "secure erase" method and if yes, what is the best one available.

I know that reboots / RAM overwrite / RAM data loss when power is off will work, but the only case considered is for access immediately following the deletion while the OS is still running.

Running shred on a file in memory is pointless. The data from the file is also likely to be present in application memory, in caches, etc. Memory that belonged to a process it not wiped when the process dies: Linux, like most kernels, wipes memory before granting it to a process, not on release, because that's faster.

Of course, there's no guarantee that the file can be recovered. But there's no guarantee that it can't, either. If your attacker model is that the attacker can see your RAM content, there's a lot you need to take care of. At the very least you need to wipe RAM pages as soon as they're released by the process. You can apply the Grsecurity patches to the Linux kernel, at least the PAX_MEMORY_SANITIZE option. And you need to be careful about what processes are running and might store confidential information. And keep in mind that the kernel stores confidential information too, such as the RNG state and disk encryption keys. The TRESOR patch to the Linux kernel protects the disk encryption keys during normal operation, but it isn't a perfect defense and I don't know of a similar patch for the RNG state.


Does certificate pinning protect against Fiddler? We have a mobile app that connects to our server via RESTful HTTPS web services. We also have an attacker who correctly emulates our app in communicating with our server. We therefore assume that our attacker is able to observe and decrypt the app's traffic using a tool such as Fiddler.

As I understand it, Fiddler inserts a certificate in the middle and acts as a proxy. Fiddler is able to provide the attacker a decrypted version of the data stream.

Should certificate pinning remove the ability for an attacker to observe the HTTPS traffic? With our mobile app in the wild, I have to assume the app can be installed on a rooted/jail-broken device.

Per this answer, cert pinning can be bypassed on a rooted Android device or jailbroken iOS device.

I would go on to state that I think that your approach of trying to secure your application by adding client-side security is doomed to fail. While you can raise the bar of having your application examined via obfuscation and other tricks, as there's no physical security, you can't secure the client.

You need to make your API sufficiently strong to withstand attack from any client. The only alternative is to maintain physical control over the clients to ensure they are secured (rather awkward in a mobile app).


Password storing in Google Chrome content scripts I am planning to store the login credentials in Google Chrome content scripts. The content scripts will then use these credentials to login to a website when I open it in Chrome.

I wanted to understand the risks / issues in storing login credentials in a content script? Also, if this is not the way to go, is there some encryption mechanism to store the credentials and these can be access by my content script?

Anyone with read access to your computer can get access to the password. Even if the database (localStorage/whatever) is encrypted. All an attacker has to do is copy over the user data directory (~/.config/google-chrome on Linux; somewhere in AppData on Windows), start Chrome on their own pc with the --user-data-dir flag set to the copied directory, and use the app -- the stored credentials will be used to login to whatever site you're using (and they can be easily sniffed via the developer tools).

Instead, I suggest you see if the service has an authorization API. For example, you can have your extension request partial permissions to the Google account. Of course, if the data directory is stolen, then the attacker has access to these permissions. Many sites (like Twitter) support OAuth, that's another thing you can try. Most OAuth-enabled sites only give limited permissions via OAuth.

Otherwise, store the password on your server, and have the server do everything -- just use your extension for communicating with the server and displaying the result. This way, an attacker can only work within the bounds of what your extension can do.

In the end, whatever method you use to secure it, an attacker stealing the data directory will be able to do some damage. All you can do is help restrict the possibilities -- with the direct password, and attacker can do all sorts of stuff like change the password. With a restricted permissions API key, the attacker can only work within the bounds of those perms. If you do everything on the server, then the attacker cannot do much outside the capabilities of your extension, since the server only knows how to make certain types of requests to the page.


What makes malware like Stuxnet or Duqu so advanced? While malware such as Stuxnet and Duqu have been known for at least six years now, they are still (to the best of my knowledge) considered to be the most advanced malware ever publicly known.

My question is, what exactly makes them so advanced? Different analyses of Duqu that I have read point to a custom, object-oriented C framework compiled using MSVC ~2008 - no fancy tools nor any novel techniques seem to have been used.

I appreciate that they used 0-day exploits and that they were extremely successful in their intended missions, but does using 0-days actually make the software itself advanced?

0days are usually fairly expensive. You have to consider the manpower required to find them. Then to find a specific sequence of 0days required to hop into a specific framework is closer to a permutation than a combination.

Figure each 0day is worth around $500k.

To find people that have those specific kinds of 0days or know how to find them, in sequence, then to write and obfuscate the code, have it self replicate only in the target systems along a limited pathway, and target very specific PLCs while leaving as little trace as possible requires a lot of very specialized skills that are perishable, a team is necessary. A team defined by mastery of digital logic and systems.

And the team has to keep their mouths shut.

It goes from being tens of millions of possible coders worldwide, to a few hundred, maybe a few thousand, fairly quickly.

As far as the software itself being really advanced... That's a matter of relativity. It pretty much all boils down to a handful of operations in assembly anyway.


How to detect authenticity Of Client and Server Certificate? How its possible to detect authenticity Of Client and Server Certificate.

For example, If server A has certificate and someone C stolen its certificate and
send it to B then How we decide that it's send by A or some one else ?

Same question for client certificate authenticity.

I know that the private key is belongs to only the correct owner, but still is there
any way to identify the sender of certificate ?

You need to trust someone. Certificates that are presented to you are checked by your verification software:

Is the certificate's upstream root certificate in your trust store? (I.e. do you trust someone who is telling you that they trust A's certificate?)
The verification software also checks either the Certificate Revocation List (CRL) or uses the Online Certificate Status Protocol (OCSP) to see if the certificate was revoked before its expiration date.
Verification also includes other checks that are beyond the scope of your question.

To answer your question a different way (using your example scenario):

It should be very hard to steal the private key for server's A certificate. For digital signatures, (my company's focus), the private keys are usually stored in a dedicated hardware appliance that includes anti-tamper switches. If someone opens the box, everything is erased.
If someone does indeed manage to steal A's private key, then yes, they can masquerade as A until either someone discovers the theft and has the CRL/OCSP system updated or until A's certificate expires.

It is for exactly the reasons that you ask about that digital signature certificates for people should be tightly controlled. A Secure Signature Creation Device should be used.

[Disclosure: I work for CoSign]


Beginner-friendly tool to simulate HTTP flood on my website Is there any easy-to-use tool available I can use to produce an HTTP GET flood on a website I maintain? If so, can you also explain in steps how to use it?

I need to do this for testing purposes. Our website is frequently the target of layer 7 HTTP floods. Seemingly a distributed bot-network is hitting the home page and taking it down in the process.

My webserver is nginx; we recently added some hardening measures to mitigate DDOS. However, it's still wasn't enough. Now I want to be able to test the efficacy of various settings.

If you were running apache then you'd already have 'ab' available. I was under the impression that 'wrk' was often distributed with nginx - it is available seperately. Alternatively httperf will do the job.


How does the Windows "Secure Desktop" mode work? Can anyone explain (or provide a link to a simple explanation) of what the Windows "Secure Desktop" mode is and how it works?

I just heard about it in the KeePass documentation (KeePass - Enter Master Key on a Secure Desktop) and would like to understand it better.

Short answer

There are three, separate issues claiming the name of "Secure Desktop":

Windows builtin functions like GINA and the Credential Provider Model.
Separation of privileged vs unprivileged applications running as the same user (nominally prevent privilege escalation), which may or may not be related to:
SwitchDesktop(), which is what KeePass is using and may or may not (I'm not sure) be resistant to DLL Injection.

Detailed answer

As a quick primer to how Windows GUIs are built, basically everything runs through a function called CreateWindow() (I mean everything, every button, every menu, everything) and is given a hWnd or Window Handle. Modifying these Windows is done via another function, SendMessage().

Here's the catch. As a user mode application, making the right API calls I can fairly easily send messages to other Windows. It's fairly trivial to make buttons disappear from other people's forms. It is a little harder to perform DLL injection and hook the message loop that receives messages (the OS sends Windows messages when things happen to them) but not that much harder. If I can hook those events, I could automatically submit your "yes/no" form. Or, I could change the label from ReallyDodgyVirus.exe to explorer.exe and you'd be none the wiser.

Insert: A really good article on the various techniques of getting your code into the address space of a running process.

Now, what are KeePass doing?

A very brief perusal of the source shows they are using CreateDesktop(), SwitchDesktop() and CloseDesktop() to create a second desktop connected to the physical viewing device you're on. In English, they're asking the kernel to create for them an isolated desktop whose hWnd objects are outside of the findable range of any other application's SendMessage().

I should point out that SwitchDesktop suspends the updating of the UI of the default desktop. I'm not sure if the message loops are also frozen - I suspect not since the desktop is created as a new thread.

In this instance, KeePass is drawing the UI, so the execution is not, as I understand it, as NT AUTHORITY/SYSTEM. Instead, the new desktop is created in isolation from basically the rest of the current desktop, which protects it. I'll be happy to be corrected on that. However, see the MSDN for SwitchDesktop:

  The SwitchDesktop function fails if the desktop belongs to an invisible window station. SwitchDesktop also fails when called from a process that is associated with a secured desktop such as the WinLogon and ScreenSaver desktops. Processes that are associated with a secured desktop include custom UserInit processes. Such calls typically fail with an "access denied" error.

I believe this means that these dialogs (screensavers, Windows Logon) are built more deeply into Windows such that they always execute as NT AUTHORITY\SYSTEM and the UserInit process creates the sub processes on valid authentication at the required privilege level.

The reason I bring this up is because I believe there are two issues: different desktops and privilege separation. From Mark Russinovich's discussion of the topic of Secure Desktop:

  The Windows Integrity Mechanism and UIPI were designed to create a protective barrier around
  elevated applications. One of its original goals was to prevent software developers from taking
  shortcuts and leveraging already-elevated applications to accomplish administrative tasks. An
  application running with standard user rights cannot send synthetic mouse or keyboard inputs
  into an elevated application to make it do its bidding or inject code into an elevated application
  to perform administrative operations.

As SteveS says, UAC runs a separate desktop process as NT AUTHORITY/SYSTEM. If you can catch UAC in action (consent.exe) via process explorer, it looks like this:

Escalating privileges as a process I don't have the specifics of, but here is what I think I understand: I believe the process of privilege escalation in the Windows API causes a process running as NT AUTHORITY/SYSTEM (therefore able to execute the new process under whatever privileges it wants to, in this case an Administrator). When an application asks for higher privileges, that question is asked to you on a new desktop locally, to which none of your applications can get either the Desktop Handle or any of the GUI element handles. When you consent, consent.exe creates the process as the privileged user. Thus, the process running as NT AUTHORITY\SYSTEM is a consequence of the need to create a new privileged process, not as a method of creating a secure desktop. The fact the desktop is different to the default is what adds security in both cases.

I believe what Mark means above is that, in addition to these secure desktops, two things are happening:

Your default administrator desktop is in fact running unprivileged, contrary to Windows XP and earlier and
Unprivileged and privileged applications now exist on separate desktops (disclaimer: could just be ACLs on the objects in memory, I'm not sure), ensuring that unprivileged code can't access privileged objects.

The Windows Logon UI is different again in Vista/7.

Clearly, none of these methods will defend you against kernel mode rootkits, but they do prevent privilege escalation and UI integrity compromise by isolating privileged applications, or in the case of KeePass, the sensitive dialog.

Edit

Having looked harder at the KeePass code, I saw this handy piece of C#:

Bitmap bmpBack = UIUtil.CreateScreenshot();
if(bmpBack != null) UIUtil.DimImage(bmpBack);
/* ... */

SecureThreadParams stp = new SecureThreadParams();
stp.BackgroundBitmap = bmpBack;
stp.ThreadDesktop = pNewDesktop;

From this you can see that in fact in order to mimic consent.exe, KeePass takes a screenshot of the background, dims it and creates its new desktop with the background of the old desktop. I therefore suspect the old desktop continues running even while it isn't being rendered. This I think confirms that no magic NT AUTHORITY\SYSTEM action is happening both with KeePass and consent.exe (I suspect consent.exe is doing the same thing UI-wise, it just happens to be launched in the context of NT AUTHORITY\SYSTEM).

Edit 2

When I say DLL Injection, I'm specifically thinking of DLL injection to corrupt the UI. DLL Injection remains possible on KeePass as a process, I'm just not sure whether it could be used to influence that secure UI. It could, however, be used to access the memory of the process and its threads, thereby grabbing the entered password pre-encryption. Hard, but I think possible. I'd appreciate someone advising on this if they know.


SSL/TLS Client certificate's key with or without pass phrase? I have a small PKI for our web server that will require client certificates.

When generating the private key for CSR (edit: CSR for a client certificate ), I can do it with or without a pass phrase.

What is the importance of using a pass phrase (or not)?.

EDIT 2: For my setup, I will be giving users a PFX/P12 file, which will have an export/import passphrase, since the only passphrase I used when importing a client certificate was the "export" passphrase, I guess the private key is included in the PFX/P12?

if so, there's not much difference for me to whether I use a passphrase for the key or not, right?

So if all above is right, , why would I want to protect the private key?

The passphrase is used to protect and encrypt the private key. You will create the private key either encrypted or not. If you encrypt the private key, it must be decrypted before use in any transaction with that passphrase.  Doing this provides an additional layer of protection over that key.

A quick read of this document will be helpful: OpenSSL Essentials


What's RSA and ECC's role in TLS 1.2? I'm trying to figure out what is RSA and ECC used for in TLS 1.2 cipher suites.

Let's take TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 for example, communication between server and client would look like this (revised according to answer below) -

C        S
|<<------| 1.   [PlainText] signed certificate
|------>>| 1.1. [RSA] Authentication: encrypted message using the public key in certificate
|<<------| 1.2. [RSA] Authentication: session key to be used as "master" for DHE
|        |
|<<---->>| 2.   [ECC] Key exchange: using DHE protocol
|        |
|<<---->>| 3.   [ChaCha20+Poly1305] Encrypted data

I guess something in this diagram is wrong, where is RSA being used?

According to other similar questions and the answer below, RSA is used for the authentication of the server.

If I understand correctly, during this auth process a session ID is created by the server (or client?) and will be used later as a master secret for DHE. Correct?

So, what is ECC being used for? To encrypt the key exchange process?

You are combining a few components.  TLS/SSL is rather complex because there are so many individual pieces which fit together.

The public key is part of the cert and the key exchange and server authentication are two independent steps which (can) use different algorithms.

The server first needs to be authenticated because DH and variants are vulnerable to MITM attacks.  You can't securely exchange keys until you know you are talking to the right entity otherwise all you did is "securely" exchange keys with an attacker.

So the server authenticates itself by signing a message using the server's private key.  The message, signature, and cert are sent together to the client.  The client verifies the signature to authenticate the server is who it says it is.  If I am going to https://example.com the browser will expect a cert with a hostname of example.com but a cert is public information.  Only the server with the private key can generate a valid signature

The RSA in your example means the algorithm in the digital signature verification is RSA.  The algorithm used will be determined by what type of public key the cert contains.  If you have a ECC (ECDSA) keypair the authentication is going to be using ECDSA.  If it is an RSA keypair the authentication will be using RSA.  DSA is also a valid option but I am unsure if CA are still issuing DSA certs.

At the same time the browser will verify the site cert was signed by a cert it trusts.  It works backwards as far as it needs until it either reaches a root cert it already trusts (because it is built into the OS) or it runs out of chain and reports the "cert is not trusted".

Once that is all that is complete the client knows it can't be MITM spoofed and is actually talking to the server in question so it can use a key exchange protocol such as RSA, DH, DHE, ECDH, or ECDHE to securely exchange keys with the server. Yes RSA can be used for exchanging keys as well as in digital signatures.

DH_DSS = Key exchange using DH. Authentication using DSA.
DH_RSA = Key exchange using DH. Authentication using RSA.
ECDHE_RSA = Key Exchange using ECDHE Authentication using RSA
ECDHE_ECDSA = Key Exchange using ECDHE Authentication using ECDSA
RSA = Key Exchange and Authentication are both done using RSA


Google Analytics: Hacked or Ghost Referers? I posted this question (Hacked or Ghost Referers) on Google groups earlier today, but I also wanted to see if the security experts here have any insight into this behavior.

I've got a web application that I'm developing locally. The server is run from a local, non-internet connected machine. The computer I access the web server is internet connected, but I simply point to the local ip address to develop the app. I'm posting here because on my Google Analytics User Flow page it shows users from Russia have accessed my site, complete with browser language setting in Russian. This wouldn't too worrying except it shows they visited multiple pages from within my site! I have no idea what is going on, whether I should be worried that there is spyware/trojans/worms or whatever running on my local machine, or if there is something weird going on with Google analytics.

Has any else experienced this issue? Should I be worried that my local machine has been compromised? Is this normal behavior for Google Analytics? How can local only traffic appear to originate from Russia, complete with browser language settings that I don't use? I have all updates and up to date antivirus.

Below is a screenshot of the users flow with urls redacted. But looking at the report it looks like Russian users have accessed multiple pages within my application.

Thanks in advance.

P.s. I only mention "Ghost Referers" because I came across this other forum post, which makes me think possibly it's related.

Either your web server is internet-accessible somehow or these are bogus-requests; you should check the access logs on your web server, if it doesn't show up there, then it's an issue with GA.

BTW, we have some servers in a datacenter in $someplace in western europe that shows up on GeoIP-matches as russian IPs, which gave us a huge "YIKES!!!!!!!! SSH-Access from Russia to our servers?" bump. If possible you should check the IPs behind the GA events and where they originate from. Robtex.com might be handy when analyzing IPs.


Help understanding basic user authentication with salts and hashing I for some reason am not understanding how to execute a secure authentication between client and server for a user. I've read many resources, and I understand how to use the hashing and salting tools, but not getting the final picture.

The user logs in from a mobile application which sends a request to a server. Here is my understanding:

The goal is to send the user's password to the server for authentication, but it is not to be sent cleartext. Generate a unique random salt for every login. Now, send the following two items to the server:

hash(salt + password)
salt

On the server side, ...ok this is where I'm totally confused. What the heck do I do here? How should the password in the database be stored - hash(password)? And the salt is stored separately? How do I verify the password? Who should be generating the salt - the server or the client? It's a messy nightmare!

Update

After reading the answers, it makes more sense now. I will be using SSL, but I just wanted to know how it would work without it. Now the question is, where do session ids tie in to this?

A. Say when a user logs in and is authenticated, the server creates a new random session id and this session id is saved in the table for that user and is sent back to the client and saved there. For every subsequent request the user makes, instead of sending a password over every time, I send the session id and make sure it matches the session id in the user's account. Do I need to do any hashing or encryption on this, or is it just as basic as sending over the cleartext session id and checking if it matches?

B. And this is another very common sense question to you guys, but say I have a POST url that does some things, and requires certain fields such as userId = self.request.get('userId'). This value is assigned by my client when sending the request. The question is, can an attacker generate their own request to that URL and fill in their own values for userId in that request, and have the request go through? I'm not really sure how that works..

In your title you are talking about basic authentication, I assume you are talking about HTTP basic authentication, which is when the browser prompts you for a password, encode and sends over the wire. However, you do not really control the mechanisms and encryptions with that method. It's also generally not used because its less secure and you can't add things like SALTs, one time pins, captchas, etc.

Likely, you want to implement form based authentication using an HTML form which sends the form data with POST. You should secure the submission of this form using SSL/TLS with a certificate for general public usage. This helps to limit the ability for man in the middle (MiTM) attacks where an attacker can eavesdrop and capture the username and passwords. You can do encryption on the client side using JavaScript, but you still need the initial password stored up front. I have seen this implementation on only a few pen tests, but its not very common to do it with JavaScript like that.

Now, in regards to salting and hashing, and everything like that. This is more to do with the storage of the credentials in the database. Typically, you receive the password without encryption through the SSL-secured form submission. You don't want to store the actual password in your database, so you hash it and you salt it using your hash algorithm (e.g., bcrypt). The salt+hash make it so you can store the password without it being directly stored. Hashes are one way so unless you use a technique called rainbow tables, you would have to brute force every possibility until you ran through the algorithm and got the same result. Using a salt make it more difficult to use rainbow tables because the rainbow table must take into account the salt and cannot just be the "standard" rainbow table.

You can have a per user salt or one you use universally, a per-user salt would be more secure. In your user table in your database you would store the following

the username
the hash(salt+password)
the salt for this user

Now, when a user comes to log in again they submit their username and password in the form. You then want to see if they are in the table so you then:

Look up the supplied username in your database and return the hash and the salt
Take the provided username and rerun the hashing function using the salt obtained in 1 to do somehting like hash(salt+password submit on form)
If the hash generated in 2, matches the on retrieved from the database in 1 then you know they provided the correct password

The whole point is to not store the actual password and to make it computational expensive to figure out what this random set of characters maps back to (i.e., difficult to determine the real password).

Some further reading

An implementation using JavaScript on the front end
A decent tutorial I probably could have googled first before writing all of the above.

Update
OP Asks about not sending through SSL:

You need to accomplish to separate things here: (1) secure data in transit and (2) secure data at rest. What we talked about with hashes accomplishes securing at rest. To secure it in transit, you need to ensure the data going over the network is encrypted somehow. It sounds like you don't want to obtain or cannot obtain a SSL certificate. This is generally the most common way. Otherwise you could implement a much more complex programatic way, where you have your own private and public keys. You more or less encrypt the data before its sent with your private key using a JavaScript implementation of PGP or similar. This is not recommend because you can easily mess it up and it requires JavaScript, which your users may not have enabled. You still use the salting as described above, you just encrypt at the client with your public key and then decrypt on the server end with your private key, then continue as if it was transfered with SSL.

Algorithm (caveat - requires JavaScript or other client side language enbaled)

Create a log in form, do not set a submit action in the form - we don't want the information sent through normal means because its confidential and we are not using SSL
Create a JavaScript handler which is used to submit the form, as part of the processing, encrypt the password field with your private key, then submit it using HTTP post.
Once received on the server, decrypt with public key
You have now transfered the actual password over the network with encryption
Change you private-public key pair frequently to reduce compromise or reversing.
Continue with securing at rest as detailed above.

Update 2
OP continues question to know more about securing session variables:

It's always best to put all submission over SSL to protect eavesdropping. Even if you hash all of your cookie data, if I can intercept and I just need to send you back the hash, well, I already have it if I can be MiTM. You should use multiple factors to limit session hijacking and CSRF attacks. Rather than going into deep detail here, you may want to check out the OWASP Top 10 and read through the various security concerns and how to mitigate. OWASP is one of the top resources for learning how to secure web apps.

The second question you are asking is if your server side app is doing logic basic on a user id being passed can this be faked? Yes, use session management to determine the current user, don't let the client tell you who they are after authentication.

This article, also related to the questions you ask and may be useful for you.


What mechanism does Firefox use to remember the in-session logins, after entering the Master Password? After I have entered my Master Password, does Firefox decrypt all the logins and store them somewhere? Or does it store the Master Password itself? Is the in-session period (more) vulnerable to attack?

The password database isn't encrypted directly with your master password, instead a hash of the master password is computed and that hash is used to encrypt/decrypt the password database.

After you typed your master password, Firefox doesn't store the plaintext password anymore and instead simply use the hashed password to access the file.


Remove Malware from files? (Except Anti-Virus) How to remove malware from files?

Files may be images, documents or videos.

Except Anti-Virus are there any other ways available?

Generally speaking, you create fresh copies of the files, transcribing only the parts that you can verify clean using methods that you can verify secure.  This may be risky.

For example, if you have a document that might be infected, you might re-type it on another computer.  Obviously, don't type parts of the document that might be virus-related, e.g. a macro you can't 100% prove to be non-malicious.  Then the new copy would, ideally, be safe.

Theoretically, if someone's got a lot of documents, they might try to automate the process:

Create a server that constructs new documents on a clean computer.
Create a client that dictates from the infected documents on the old computer.
Obviously, don't have the server simply copy everything – instead, have it recreate only content that's definitely safe; everything else will be lost (unless you want to take some calculated risks).
Allow the client to connect to the server over a secure format that you're willing to bet the infection can't side-channel through.

For example, if you copy it by hand, then you're betting the virus can't hack your brain.
For example, if you copy it by a network socket, then you're betting that the virus can't hack the server through whatever network protocol is involved.

I'd speculate that someone's probably set up a service centered around this where:

They operate a server with appropriate security measures.
Users can download a client onto their infected machine.
The client dictates the files to the server, which allows reproduction of verified-clean material.
Users can download the verified-clean documents from the server onto a new device.

That said, I can't recommend a service that does this.. just seems like there should already be one, or else it could be a potentially great side-project for someone.  Obviously, you'd need to be able to trust the service provider.

Finally, to be clear, trying to recover infected content can be dangerous.


How can I manually add login credentials through the Windows Credential Manager? For example I'd like to add the Steam login credentials, since the browsers won't ask to save the password. Is there a way to do it manually?

If I choose to add a new windows credentials and put in the url form: store.steampowered.com and then my Username and Password it won't show up anyway during the login.

Is there a way to do something similar for App logins (e.g Steam client)?

Go to step 4 of this:  http://windows.microsoft.com/en-us/windows7/store-passwords-certificates-and-other-credentials-for-automatic-logon

Enter a DNS name (store.steampowered.com) along with the credentials and it should work.

Please note (and in your question you even state this) that this won't work the same way that a password manager such as LastPass would work; there are more autofill and autologin functions associated with a password manager than there are with Credential Manager.

Let me know if this isn't what you're looking for, thanks.


Can SMS messages be traced when they come from a computer? From Amazon SNS, I can send SMS messages to any mobile phone.

To recipient phones, the SenderId is just a string of my choosing. The messages cannot be replied to.

I receive quite a few phishing messages that appear to be sent via a similar mechanism. I can't reply 'stop' and the sender ID is just a name.

Is it possible for network operators to trace these types of SMS messages back to their sender? Or is the inter-network protocol completely anonymous?

There is Data retention requirement for various country telco. AWS SNS is simply a services proxy to SMS telco, so, no exception.

However, since it is a lucrative business for both telco and Phish spammer as point out here, and it take expensive resources to track down and shutdown the operation, so you will not see the end of it.


Why do browsers not protect against scripts coming with images? I understand that this is how it goes:

Malformed Image --> Buffer Overrun --> Stack Over Flow --> Execute Malware Pushed On Stack

And though I don't a huge amount about this, I know that I have had many of these malicious scripts come with images before that have done nasty things within my browser hiding in my cache, but why does do most browsers not protect against this? Is this something exploited through vulnerabilities (if so, there seem to be far too many of them as I've had far too many of these malicious scripts)? Or why is it so difficult to have protection against this?

I just understood from here that browsers don't protect against these things and I want to know why.

You did answer your own question already:

  Is this something exploited through vulnerabilities   ...   Buffer
  Overrun

Buffer overflows are not intended behaviour, but indeed exploitable vulnerabilities. Browsers vendors will fix B.O. when they find it => they do protect from it. The problem is, as with all vulnerabilities, someone has to recognize that there is an error in the code first.

What your chat log says, that browsers don't use some preventive additional security features which could help against an existing error being exploited (eg. because these methods have downsides too). But they will fix the errors itself.

  as I've had far too many of these malicious scripts

That could have thousands of reasons, other than images with scripts. Given that you seem to think that "buffer overrun" is always the same as "stack overflow", you probably didn't recognize some of the reasons.


Tls certificate correspondence I am not really good in tls details, just know some basics.
So there are couple of questions about it:

Is there a way to decipher tls in wireshark if the cipher method is diffie hellman? I know that using web browser it is easy as I have session key there. But in general case how I can extract session keys if I just have tls over bare tcp?
If I have multiple clients who connect to the server, how does the server distinguish between different certificates and chooses the right one to decipher the message?

I am not really good in tls details, just know some basics.

In this case I really recommend you to read How does SSL/TLS work?.

  Is there a way to decipher tls in wireshark if the cipher method is diffie hellman? I know that using web browser it is easy as I have session key there. But in general case how I can extract session keys if I just have tls over bare tcp?#

The point of TLS is to protect the transport against sniffing. This means if properly used there are no information inside the TCP connection which allow the decryption. Only client and server have the necessary information to encrypt and decrypt the data.

  If I have multiple clients who connect to the server, how does the server distinguish between different certificates and chooses the right one to decipher the message?

The server does not use certificates to decrypt the traffic. The certificate is only used for authentication to prevent man in the middle attacks. In case of RSA key exchange the server certificate is additionally used inside the key exchange.

It is common that a server has only a single certificate. If the server has multiple certificates for different domains then the client needs to specify which domain it wants to access inside the SNI extension of the ClientHello (first message of TLS handshake).


Why would a stealth scan attract more attention than a connect scan? I'm reading an Information Security book and am faced with the question:

  Why may nmap stealth scans(SYN) attract more attention than simple connect
  scans(TCP connect())?

Why might it be?

Nmap, like any adversary tool, can be fingerprinted by Intrusion Detection Systems (IDS). As such, any of Nmap's techniques are generally classified as an attack by these modern tools -- especially Next-generation Firewall (NGFW) technologies, or the bleeding-edge equivalents of NGFWs.

Additionally, information sharing alliance centers (ISACs) are sharing Cyber Threat Intelligence (CTI) indicators (often shown as Indicators of Compromise, or IoCs) that involve either

IP addresses that original attacker traffic, such as Nmap, and thus would be blocked or detected by an organization that has a CTI team, consumes CTI feeds, or has products or service that include a CTI element
Network traffic signatures, such as Snort (N.B., Snort is a very popular free, open-source IDS) rules, that contain information about how Nmap works -- especially Nmap's "stealthy" scans, e.g., NULL, FIN, ACK, Window, SYN, et al

Which book are you referring to? Given the context, it appears that the author is discussing how SYN scans are potentially more noisy on a network than TCP connect() scans. This is because the SYN scan does not complete the full TCP handshake. Again, IDS/IPS, UTM, NGFW, and CTI defensive techniques will detect the SYN scan, much like many other Nmap methods and many other network penetration-testing tools and techniques.


Is there an overview over all OAuth2-related specifications? I recently started to read up on OAuth2, and just now noticed how many extensions exist to this protocol. Is there an overview or some kind of a map of OAuth2 and all of its (official) extensions? I was hoping that something like in the diagram below somewhere existed.

If no such document exists, then I would like to know which official OAuth2 extensions there are. I could only find an official site for OAuth1 extensions.

I know of the following extensions:

The OAuth 2.0 Authorization Framework: Bearer Token Usage
OAuth Assertion Framework
OAuth JWT Assertion Profiles
OpenID Connect protocol suite
SAML 2.0 Profile for OAuth2.0 Client Authentication and Authorization Grants

I found quite useful the diagram represented under the openid website OpenID Connect Protocol Suite. You can click on the boxes in order to see the specification


Is there a legitimate reason I should be required to use my company's computer? (BYOD prohibited) I just got a new job at a medium-sized (~100 employees) company and one of the first things I was told is that I cannot use my own computer, because I need to be able to connect to their network, access files, etc. I didn't think that made much sense because to my knowledge, as long as I'm on their network, I should be able to access anything I need to.

So I asked my friend this question, who told me it might be a security thing. Could there be a security-related reason as to why I'm required to use my employer's machine?

So this is an interesting question with a few points into why you not only should WANT to do this, but should do this for your own safety and security. It helps first if you understand that companies point of view before we talk about how it can benefit you.
Why would a company want to do this?
Many reasons. It makes it assured that your computer can access the network, do what it needs to do, and function how they need it to at a baseline. This way the IT department can maintain it easily, quickly, and up to standard.
Can they make me do this?
YES THEY CAN! They are having you work on their property, with their property, to make sure it works properly. This way you can actually do your job.
Should I do this?
Oh god yes.

This lets you pass the buck if needed. Now if something that is supposed to work, doesn't work, it isn't your fault.
Maintenance becomes a breeze because if your files are backed up to a safe place (any installers you used as well), then if something really bad happens they can restore it to a disk image and have your computer back to you in the matter of a few hours instead of days.
IF you leave the company for any reason, you don't have to relinquish your personal computer to them for driver scrubbing or making sure you don't take any company software or intellectual property with you.
IT has no claim to touch your personal computer for any reason.
For security reasons, you can make sure that your work computer is up to their standards and any potential breach won't be your fault, but their bad policies' fault.

And here's the whammy: It keeps you safe from the company!
In using the company computer your own personal information won't be on the company network, and you can keep your private life away from your work life. This is a big advantage because you can make sure that your own data, is your own data.


I delete cookies file in chrome but i'm still logged in after I restart Chrome I'm using linux and google chrome as browser. I know that cookeis are stored at /home/my_name/.config/google-chrome/Default/Cookies.

I deleted this file but it seems like when I restart Chrome and try to browse for example facebook, website logs me in. So I got little confused why do websites still authenticating me even if I don't have cookies file.
So my question is this. Is stealing Cookie file enough for someone to log in into any website that I was logged in? Hope you can help. Thanks.

Local storage?
In modern browsers Facebook also uses "Local Storage" (although I don't know if for login), which is different from plain old cookies. (Check using the F12 key.)