Wordpress 4.7.6 vulnerabilities? I have a wordpress 4.7.6 without plugins, however, I've noticed this: https://cxsecurity.com/cveshow/CVE-2017-14723 And the other vulnerabilities that are <4.8.2.

My question is, I have tried to search how to exploit it in my wordpress, but I do not find how. I appreciate your help and well, I am assuming that if it is <4.8.2, it is vulnerable, right?

If you check here you will see that WordPress versions 4.8.1 and earlier are affected by nine security issues:

  $wpdb->prepare() can create unexpected and unsafe queries leading to potential SQL injection (SQLi). WordPress core is not directly
  vulnerable to this issue, but we’ve added hardening to prevent plugins
  and themes from accidentally causing a vulnerability. Reported by
  Slavco.
  A cross-site scripting (XSS) vulnerability was discovered in the oEmbed discovery. Reported by xknown of the WordPress Security
  Team.
  A cross-site scripting (XSS) vulnerability was discovered in the visual editor. Reported by Rodolfo Assis (@brutelogic) of Sucuri
  Security.
  A path traversal vulnerability was discovered in the file unzipping code. Reported by Alex Chapman (noxrnet).
  A cross-site scripting (XSS) vulnerability was discovered in the plugin editor. Reported by 陈瑞琦 (Chen Ruiqi).
  An open redirect was discovered on the user and term edit screens. Reported by Yasin Soliman (ysx).
  A path traversal vulnerability was discovered in the customizer. Reported by Weston Ruter of the WordPress Security Team.
  A cross-site scripting (XSS) vulnerability was discovered in template names. Reported by Luka (sikic).
  A cross-site scripting (XSS) vulnerability was discovered in the link modal. Reported by Anas Roubi (qasuar).

So yes, you should updated your Wordpress to the latest one.


Confused about RFC 4492: difference between "ECDH-capable public key" and "ECDSA-capable public key" As per section 5.3 of RFC 4492, I'm confused with the following table:

          Key Exchange Algorithm  Server Certificate Type
      ----------------------  -----------------------

      ECDH_ECDSA              Certificate MUST contain an
                              ECDH-capable public key.  It
                              MUST be signed with ECDSA.

      ECDHE_ECDSA             Certificate MUST contain an
                              ECDSA-capable public key.  It
                              MUST be signed with ECDSA.

      ECDH_RSA                Certificate MUST contain an
                              ECDH-capable public key.  It
                              MUST be signed with RSA.

      ECDHE_RSA               Certificate MUST contain an
                              RSA public key authorized for
                              use in digital signatures.  It
                              MUST be signed with RSA.

Specifically, I would like to know about the difference between

  ECDH-capable public key

and

  ECDSA-capable public key

What actually defines an EC*-capable public key and what are the differences between the two?

I am using XCA/OpenSSL and have configured a CA and signed server certificate to use a prime256v1/P-256 EC key. Then, I will have a client/server using the following cipher suites:

  TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA

and

  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA

That wording is an abbreviation; the key is (or keys are) actually the same, the difference is whether the certificate allows use of the key for the relevant purpose. See section 2:

  Note that there is no structural difference between ECDH and ECDSA
     keys.  A certificate issuer may use X.509 v3 keyUsage and
     extendedKeyUsage extensions to restrict the use of an ECC public key
     to certain computations [15].  This document refers to an ECC key as
     ECDH-capable if its use in ECDH is permitted.  ECDSA-capable is
     defined similarly.

[15] refers to rfc3280, which has been superseded by rfc5280. If the KeyUsage extension is present in the cert, it has the digitalSignature bit set to allow use of the subject key for ECDSA, and/or the keyAgreement bit set to allow use of the subject key for ECDH. If KeyUsage is not present, the key can be used for any purpose otherwise acceptable to the program(s) using the certificate.

In principle ExtendedKeyUsage can also be used, but I'm not aware of any EKU values defined -- and more to the point, implemented by common software -- for these specific usages. (There are lots of EKU values defined for other things, including distinguishing server SSL/TLS from client SSL/TLS.)


Drupal 7 - attack in the logs In my Drupal 7 logs I see entries such as:

http://example.com/?q=file/ajax/name/%23value/form-tkSDwR6W66a8vR_AIDxAzwMVklkjTkNMjf8SEqfTX8Q

There are several entries like this one, with only the last string changed.

It is by an unauthenticated user.

I tried to access the URL as well, and I get the following:

[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","themename":{"topoptiontext":"Page selection"},"ajaxPageState":{"theme":"themename","theme_token":"xxxxxx"}},"merge":true},{"command":"insert","method":"replaceWith","selector":null,"data":"\u003Cdiv class=\u0022messages error\u0022\u003E\n\u003Ch2 class=\u0022element-invisible\u0022\u003EError message\u003C\/h2\u003E\nAn unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (128 MB) that this server supports.\u003C\/div\u003E\n","settings":null}]

In the above log entry I removed the name of my theme and replaced the toke with xxxx
I guess the attacker did not manage to get in.

My site is patched to the latest version 7.58

Should I worry about it? Is there something that I should be doing to prevent it?

Many thanks

This looks like part of an attempt to exploit CVE-2018-7600 aka SA-CORE-2018-002, the vulnerability that was fixed in Drupal 7.58 (and 8.3.9, 8.4.6 and 8.5.1). This was being widely exploited at the time this question was asked.

If you were already running a fully patched Drupal then you were not vulnerable to this attack. However, Drupal 7.58 is now known to be vulnerable to a similar attack, so you should make sure to update to the latest version, if you haven't already.

Generally anyone using Drupal should make sure to keep both Drupal core and any modules and themes they use up to date (this is true of all software). Drupal publishes its security announcements, along with information about how to get notified when they become available, at https://www.drupal.org/security.

If you have any Drupal sites that are still not patched, see https://www.drupal.org/docs/develop/security/your-drupal-site-got-hacked-now-what.

If you're interested, you can add $conf['sanitize_input_logging'] = TRUE; to your settings.php file (on a fully patched site) to enable additional logging of detected attempts to exploit this issue. You will then start to see messages about "Potentially unsafe keys removed..." in your watchdog log when an exploit attempt is detected.

The original attack (for Drupal 7) is in two parts. The first part makes a crafted request to a page with a form, usually the password reset form, to store a special value in a cache; the second requests the /file/ajax... URL in a way that tricks Drupal's form API into misinterpreting the cached value and  executing some code contained within it. The first request is the one that will be sanitized by the fix in Drupal 7.58. The second is what you're seeing in the log here. (The additional fix in Drupal 7.59 adds additional sanitization for both). The random value is the cache key, known in Drupal parlance as the form build ID.

I guess an exploit of CVE-2018-7602 might look similar, although the announcement seems to indicate this one isn't exploitable by an unauthenticated user, and in any case details weren't public at the time.


How should we store & share documents with restricted access Up till now we have handled restricting access to documents by having a share on our server that only the 2 accounting people could access and another that only the 2 HR people could access. And everything else is available to everyone.

We've grown to a size where this doesn't work well. To continue with this approach we would need 5 different shares. And people will probably make mistakes putting files in the wrong share.

What should we do? We're only 32 people and I don't want to bring in some complex mess. But I do want to have a system that will work up to 100 employees.

We're a Windows shop if that makes a difference. And this is mostly DOCX & XLSX files.

ps - I figure this is a valid question, either as security policy, security tools, and/or physically securing information assets.

If you have an Active Directory or similar centrally managed user system, this should be quite easy to implement. Active Directory has had Access Control baked in for over a decade now.

https://technet.microsoft.com/en-us/library/cc785913(v=ws.10).aspx is an article set from Microsoft that explains this in great detail. Roughly speaking:

Create a folder system that indicates what each kind of document is for.
Define an Active Directory group setup for your different teams: one for HR, one for Accounting, one for developers, one for the helpdesk, one for management and so on.
For each group, configure the permissions that group should have to each folder. This can range from full permissions, read, write to no permissions.
Assign all your employee AD accounts to the correct group.

If you don't have a centrally managed user system with a company of 32 employees, GET ONE ASAP. It will only make your sysadmin's life easier, and it's a worthwhile investment for a company that's going to expand to 100 or more people. In addition to access control, central user management allows for much more flexibility in user management and password management and allows you much more control over not just files, but Windows settings as well.

  And people will probably make mistakes putting files in the wrong share.

This is just a matter of educating your users on proper file management. You won't be able to find a 100% technical solution unless you start going into intricate (read: unstable) in-house development projects. Use a combination of existing, well established software and user training.


Does a DDOS attack on an application using CDN have to first bring down all the involved CDN servers to affect the application's availability? CDN are said to absorb and mitigate the Denial of Service and DDOS attacks. Consider an application that uses a CDN provider to deliver its content. So if an attacker tries to bring down such an application using DOS or DDOS, the flood of requests made during such an attack will go to the CDN servers. Will such a DDOS attack have to completely bring down all the CDN servers serving this application's content before impairing the origin server completely?

Will such a DDOS attack have to completely bring down all the CDN servers serving this application's content before impairing the origin server completely?

The CDN provider might decide that this attacks is too costly and too much impacts other clients protected by the CDN that it will no longer serve your domain. In this case your domain will not be directly brought down by the attack passing through your system but will be unreachable anyway.

Apart from that your application might have bugs which make it possible for already few requests to cause a large load - like causing lots of requests to the database or algorithmic complexity attacks. In this case only a few requests will be enough to cause a high load and will make your server unreachable. While WAF capabilities in a CDN might protect against some known attacks like this it cannot protect against arbitrary bugs in the application.


What is the best way to know current attack for a server machine? I'm hosting centos 7 servers which are exposed to the risk of malicious attacks.
I have to protect the machines from the attacks.
What is the best way to know

how to protect attacks from system level
and
what kinds of attacks are exist up to date?

Thank you

To prevent attacks, there are many tools and techniques you can use. I can't really go into all of that here. A fast few tips to get started:

Update everything
Configure your firewall
Configure user permissions and make sure processes that don't need root run as a user with minimal amount of permissions
Configure any network facing services (those you allowed on the firewall)
Consider if you need some sandboxing, such as firebird
Consider getting an IDS and configure it properly

As for what kinds of attacks exist, one of the best places to look would be the CVE Database. You should also follow bulletins from your CSIRT.


Root server hacked via httpd - consequences and future prevention Since before mid 2014, my root server was targeted by hackers and recently they gained limited access. I disabled all services once I realized the server has been compromised and started investigating. According to the logs, this was approximately one week after the successful intrusion.

I used to host a website for a friend which was based on the Joomla CMS. During investigations I realized the website was severely outdated and practically abandoned. As his domain and site was the primary target, I suspect the attackers exploited known bugs or security flaws in the software to upload their own scripts, mainly to send spam email.

I just learned that one big issue is in fact, that all websites have the same user. Once the hackers gained access, they could execute server-side commands with this user (which is "www-data").

I wouldn't mind if this would have only affected my friend's site, but unfortunately they created a script in one of the other domains (which up until that date only showed an empty index.html). The file is a variant of the PHP remote shell called WSO and is the main reason I am asking for help. Before I wipe and re-install my root server, I want to make sure this won't happen again and want to ask these questions:

Apparently the hacker managed to install a php script outside the boundaries of the outdated/broken domain. How did he do that? Shouldn't nginx or php5-fpm have some sort of mechanism to prevent php scripts accessing directories outside of the current domain's root?
I know that some CMSs like Joomla ask you whether you want to use the php mail() function or an SMTP server. How can I strictly prevent php from sending emails by mail() and only allow authenticated smtp?
Is it possible to completely encapsulate the website of my friend, so that once a hacker manages to inject some script, it won't help him accessing any other website, let alone the file system of the server?
What is the ISP way of restricting customers' scripts and email sending behavior? Is rate-limiting the sending of emails good enough?

The attacker had access to all other virtualhosts (what you call "domains") because they all run under the www-data user, once he got this user's privileges he could access all the other domains.

To mitigate this you can use mod_privileges on Apache to run each virtualhost under a different user account, and make each virtualhost use a different PHP-FPM pool that also runs under that same different user. If an attacker manages to gain shell access under one's virtualhost account and attempts to ls someone else's virtualhost directory, he'll only get a Permission denied error (unless that "someone else" ran chmod -R 777 on his directory, but then he just deserves to be compromised).

The PHP open_basedir directive may also help but isn't bulletproof and will only protect against reading files using PHP's usual file I/O functions, but not by executing shell commands.

  How can I strictly prevent php from sending emails by mail()

PHP has a configuration directive to disable certain functions, so as a dumb solution you can use that, but it won't protect against using raw sockets to connect to a mail server and dump spam in there. The best solution is to block outgoing connections to port 25. Authenticated SMTP can use the submission port (587) so legitimate users will still be able to use their own mail provider's server or the server your provide, but won't be able to scan for open relays on port 25 and try to send their spam.

  Is it possible to completely encapsulate the website of my friend

You can put each server into a chroot jail and running on a different port, and have a lightweight web server in front of them acting as a proxy to redirect connections from the standard HTTP(s) port to the correct chrooted server based on the domain name. You can go even further by using LXC (containers) or entire virtual machines/physical servers for this, depending on your security requirements.

  What is the ISP way of restricting customers' scripts and email sending behavior?

Some (bad) ISPs just block port 25 to anything but their own servers (from where they can track the user even if he doesn't authenticate because they know which IP belongs to who), some let you use the port freely and I assume just terminate your account if they get too many complaints about spam from your IP.

From reading OVH's (a popular french ISP) terms and conditions they appear to monitor your outgoing SMTP traffic and pass every main through their Spamassasin-based filter, and if too many mails are considered as spam they block your port 25.


Is it safe to attach a potentially malicious hard drive to a Solaris machine? We bring in hard drives from un-trusted sources and would like to ensure that they will not contain any harmful content.

What kind of risk is there for Solaris? As in, if Solaris is running, and I attach a drive, I would run format and then check there is only one fdisk partition and it covers the whole drive, then I would run verify in format in order to erase all the data (and test the drive). Is this foolproof? (short of an actual computer inside the hard drive)

I know on Windows there are or have been all kinds of vulnerabilities or auto-run functions. I want to know if I can use Solaris in order to eliminate this problem entirely.

An adversary who is aware of your procedure could manipulate the hardware to exploit the tools you are using. The filesystem driver itself and any automatically executed programs after mounting the drive can be attractive candidates for this.

However, this would be a rather obscure attack. Since you only look at the partition table and the format tool likely also considers inconsistent drive data, your risk is probably rather low. As long as you don't mount partitions from unknown sources, there should be no problem.

Another even more obscure attack would be to manipulate the hard drive such that it uses DMA to compromise your system. This is even less likely and probably what you mean by "computer inside the hard drive".


What does "by continuing you agree to share resources" on a website mean? I recently encountered this message on a website:

"By continuing you agree to share resources. Your browsing speed will not be affected."

When I get 'learn more', it redirected to me an obscure digital currency webpage (I forgot the name). It was something like Bitcoin. What happens when I hit 'continue'?

What exactly does 'share resources' mean? I know that Bitcoins need huge computing power to mine a coin, but the webpage I was redirected did not mention bitcoin. If it's something similar to bitcoin mining, does the webpage use my resources when I'm not on the webpage?

It means that this website uses a Javascript cryptocurrency mining script.

The resources in question are your CPU/RAM/GPU which will be used to mine coins for the benefit of the website owner.

It's another form of website monetisation, like ads or data selling.


Does Hash/Salted password really help when DB is compromised? I came across this article  and got a basic understanding hash, salt and brute force attack.

My question is in the article, the author emphasises how hard it is to reverse the hash/salted password to the original one. But if the intruder has write access to the database, he can

create a new account with pwd "12345678"
record the hash "69410532sfb9234234" (just an example)
change other accounts hashed pwd into "69410532sfb9234234"
login from the front end as other account holder via pwd "12345678"
profit

Did I miss something here? Or is write access to db nearly impossible to get? The latest steam and psn databases don't give any detail if write access is compromised.

Hashing passwords is a defense against a specific attack. The attack is: stealing a copy of the entire password file (users table, ldap db, etc), downloading it to one's computer, and attempting to retrieve the users' passwords. The goal of the attack is: to find users who reuse their usernames and passwords across websites, and log into those users' email, bank, social-network, and other accounts.

The hashing-passwords defense works like this: the passwords are not stored directly, and any attempt to retrieve the original passwords requires the attacker to perform an extremely large amount of work, at least compared with the work required to check whether a password the user enters when logging in matches the password on file. There are multiple variations on this defense, including choosing better hashes, salting the hashes, iterating the hashes, etc., the purpose of them being to make the defense better than otherwise and to defend against variants of the attack which are capable of getting around the simpler defenses.

The hashing-passwords defense is not a defense against just any attack. For example, it doesn't help against an attack where the attacker gains arbitrary write access to the database, rewrites all users' passwords to his own, and logs in to all the users' accounts on that website. The defense only defends against the offline password-stealing attack.

So you need to be aware of the different types of attacks, and to defend against each of them using a defense which works against that type of attack.


Limited remote access to a web application I would like to set up a very simple node.js web application on raspberry pi and access it remotely, from outside the LAN.

There are no other hosts in that LAN with the Raspberry. I only need to access the web application from single location which has static IP assigned by ISP.

Is it possible to configure a firewall on a basic router with 'deny all, allow x' type of  filter, x being my static IP? Also, is this security measure enough?

Please feel free to recommend ways of maximizing the security of my project.

Relaying purely on IP address to perform authorization is a bad idea. IP address can be spoofed.

Rather than attempting to verify user from the server, you should let the user prove to the server that they are authorized. This can be done by using simple login and password system. If you feel like this is not good enough you could always add 2NF. Here is a tutorial on how to implement 2NF in node.js, through bare it in mind that this is the first tutorial which I found on google. As it seems from this tutorial it should be relatively easy for you to implement 2NF for you application, and could result in higher security.

Another reason for why not to limit by IP address is, assume that the network from ISP goes down, or you are too far away from the network with specific IP and you must perform some action on the Raspberry. If you do authorization you could perform this action from the phone using mobile data. If you however block all different IP addresses, then your life will become harder in such situations, where this idea provides not enough security as the IP address can be spoofed.

While this post is based on PHP login system, I believe that the principles given there may be also useful for you.


Find DNS Server of an IP over Internet I know that many clients in the same network has a same DNS (Most of time but it can be changed.)

But is there anyway to understand what DNS Server that an specific IP (Over Internet) uses through the weaknesses in UDP ?

Update 1 : It's clear that it is possible to see DNS Packets with MITM attacks.
Lets assume that example.com's IP Address is 1.2.3.4 so I mean what DNS Server this IP uses when wants to ask for someone's IP.

I ask it because I saw that Michael Howard in "25 deadly programming sins" explains that its possible to find someone's DNS Server over Internet .

But I can't find anything about it with googling.

By weaknesses, I mean that every time you ask a DNS Server for an IP the replay can be from different source (and it's normal in DNS Servers and most of Operating System will accept it ! ) and you know that UDP source IP's can be spoofed easier than TCP (as DNS uses UDP).

The answer on how the attacker might find your DNS is actually explained
 in "24 deadly sins of software security"  you probably refer to:

Either the attacker is in the same network and uses the same server or can sniff what server you are using.
Or the attacker can provoke a DNS request to its own domain (where the attacker has full control over the DNS server) from your host. This can be done for example with a targeted advertisement in a website, a link in a mail etc. The attacker can then see where the DNS request originated which is probably the server you asked to resolve the hostname. Of course this only works if you use public servers and not a recursive DNS server inside your local network.

No "weakness" of UDP is needed to get these information.


What devices/types of devices typically have unique associated ID numbers? Background (not necessary to read; just what makes me ask):

Say someone's computer has either been hacked, or is running software run by $LARGE_EVIL_CORPORATION, and the hacker/$L wants to collect as much information as possible about the person whose hardware they've owned.

Now assume the hacker/$L also has software running on another of the person's machines. On one machine, the user does personal things (e.g. finances), and on the other machine they don't (i.e. they try to remain relatively anonymous).

But, since they're the same person, they tend to use the same mouse on both machines. And the same external HD. And the same webcam... etc., ad absurdum.

How many/which of those devices would have unique device identifiers such that the external observer could link the two identities?

Even if they had no internal drive, and only booted from live CD, would it be possible/likely that the motherboard chipset, RAM, screen, or CD drive itself could provide unique identification (assuming root privs, or their O/S's equivalent)?

Additionally...

What devices would allow a unique identifier to be set (other than mass storage; those obviously have state)? Is it possible I have a webcam which, unbeknownst to me, has some flash memory that an O/S could use to assign it a personal identifier?

Well hardware fingerprinting is done by many rootkits, for instance it's a tool used by the famous cheat-prevention system "Punkbuster" so that even if you buy a new key for the game and even reinstal your system, you remain banned.

They collect different data from your machine of which some  might be relatively unique, like:

MAC-address
Motherboard serial number
device GUIDs

Some of these might be unique, other's wont. Now the idea is that you collect this data and you save it somewhere remotely and assign an id to it. Let's say computer A. Now next time the machine boots some of the ids might have changed, like the MAC address, because the user was spoofing it.

Now you collect the same data again and call this computer B. Now you do this several times and you can also keep track of when the machines were online.

From here you can do a basic filter, if two machines were up at the same time, they probably are two different machines. (first decision node)

Every piece of hardware can be awarded a certain score for reliability (more reliable to stay the same (CPUID (which is disabled these days) or your motherboard serial number), less reliable to stay the same (MAC addresses). Then you can make a scoring system an attach it to a probability.

This probability can then give you a percentage of chance the systems A and B are the same. It's actually just some basic datamining.


Ways to make it more difficult for data to be lifted from a website? Assume for a moment that I run a public-facing website that hosts pictures and names of people in a "billboard" fashion (i.e. you do not have to register to view the information) and that my site suffers from "copy-cat" sites copying my pictures and names and posting them as their own, often asking for money and using the information to loosen their readers' purse strings.

Is there any way to make it more difficult for custom-made "bots", "spiders" or other software to automatically grab the information from the page?

Are there any considerations I should take to help minimise the risk of theft (for want of a better word), both for automated theft (e.g. software based) and for manual theft (e.g. copy/paste / screenshot grabbing)?

I appreciate that once something is put on the internet, it's out there "forever", but I have thought of the following ideas so far and am looking for more (if there are any):

Adding a watermark to the images would help to reduce the ease with which copy-cat sites can pass my images off as their own (but may have an impact on the effectiveness of the images, unless there's some way for me to somehow remove the watermark when the image is displayed through my site)
Forcing my users to log in would help to reduce the exposure of data to bots (but may have a significant impact on the numbers of viewers and/or the effectiveness of my site)

I got one simple solution for all your text information.
Use a text -> image converter in order to convert names into text. http://Who.Is does this simply by displaying names of individuals as images which cannot be simply copied by bots and sets then off course.

Another solution is using reCaptcha or a more secure equivalent  (considering that certain advanced bots can crack that too even now). Fundamentally get to popup every once in a while for a particular amount of requests sent from a single client. For legitimate usage it should barely even cause an inconvenience.


How can I avoid sending passwords in plain text when logging into a website? Suppose that I login to a website. When I type my personal data, aka, password and email, the password is sent in clear text to the server, correct? Then, a network card in promiscuous mode can capture the password?

How this can be avoided?

https is designed to prevent this kind of attack: The communication between you and the server is encrypted. The server will provide a certificate to ensure that it is the correct one and not a man in the middle.. If the certificate is signed by an certification authority trusted by your browser, the connection will be accepted automatically. Otherwise you will get a warning about an untrusted certificate. If you are in doubt, don't click it away.

There is really no excuse not to use https for login, as simple trusted certificates are really cheap or free of charge. https should be used for everything, but some huge sites argue that it uses too much processing power.


Why is a password saved putty private key 48byte and a non password protected private key 36byte of length I'm currently working on a library with secure authentication process. I wanted to support ppk file loading for ed25519 private keys. I used the original source code of putty to determine how the decoding of password protected files worked. I generated a demo file with a password protected and a non password protected private key. Decrypting both files turned out that the private key of the password protected file was 12 bytes longer, both decrypted private keys shared the first 36byte. They both had the same public key.
From the putty source code i can't see any sublisting. Am I doing something wrong? Other libraries have have the same result.

Password protected private keys are simply private keys that are encrypted using symmetric encryption (e.g. AES), with a key that is derived from the password (e.g. PBKDF2).
AES works in blocks of 16 bytes.  Being that your underlying plaintext (i.e. the private key) is 36 blocks in length, it must be padded up to a length that is a multiple of 16 bytes.  That could be one of the reasons for the additional 12 bytes that you are seeing.
Also, key derivation functions usually utilizes a random salt, to mitigate against dictionary attacks.  The salt is not a secret, so it is generally stored along with the ciphertext.  So, another possibility is that some or all the additional bytes are used to store the salt used in the key derivation function.


How to be completely anonymous online? I recently saw this post on reddit: How to be completely Anonymous online (June 2012).
But the majority argument, both on reddit and on comments on that post seems to be that it is not possible to be completely anonymous.
Is it possible to be completely anonymous?
How credible are the tips on that post?
How can I have a complete anonymous setup?

To answer your question about whether it's possible, I will say it is next to impossible to be completely anonymous online. I will address the major issues that lurk outside the realm of technology.

People make mistakes and even the slightest mistake will break the "completeness" of anonymity. Mention the weather or forget to enable your proxy and you're done for.
Behavior can be analyzed (e.g. slang and idioms may locate you).
Behavior can be correlated (e.g when you are home vs online)
You have to connect somehow. Everything between your body and your means of anonymity is exposed.
Some offline threat may out you.

I also have a philosophical objection to the concept of complete anonymity. Any behavioral pattern/tendency - no matter how subtle it is and no matter how many aliases you have - exists. That is your identity and it is out there for all to see. This doesn't just include having a public social presence either. What type of links you click, what sort of things you download, etc. per session may not be able to be easily correlated with other session, but it is still a potentially consistent pattern and you.

For advice on staying anonymous, I direct you to "How do hacking groups register domains remaining anonymous?". The concepts there can be applied to other transactions.


Plain text Rails environment variables and security I work for a healthcare company that emphasizes security, due to the sensitivity of the data that we work with. Recently, we've been doing a lot of auditing (internal and external) of our current "stack" to ensure that we're compliant with various client requirements.

One recent topic of discussion is around environment variables. We use the dotenv gem, so we're storing many of these variables in a .env file (ignored in git) on the web server. These variables include our database credentials, SMTP credentials, and various API keys.

When certain leadership learned that such credentials were stored on the web server in plain-text they expressed concern. That concern has sparked discussion around encrypting those variables. I see the merits of encryption and it would certainly be valuable for protecting our API keys and the like. However I question the value it offers for protecting the data stored on our DB server (which is ultimately the biggest concern)... what we're talking about here is a malicious user gaining access to our web server. Unless I'm missing something, that user could still open a rails console, which will load the application, handling decryption of the credentials, and allow them to query the DB using our models (Patient.all, for example). It just seems to me that if our web server is compromised we're hosed regardless of whether we encrypted those variables. Am I right about that?

Assuming that I am, how do I respond to this inquisition with something more concrete than "well, that's just how Rails works" (with regards to being able to open a connection to the DB via rails c)?

What matters here is a question of threats and of defense lines. The threats I can imagine are:

a vulnerability in the web server allows an attacker to read files from the web application folders
a vulnerability in the web server allows an attacker to read the environment variables of the application
a vulnerability in the web server allows an attacker to execute arbitrary commands on behalf of the legitimate app
a vulnerability in the server (independantly of the web application) allows an attacker to gain access to the server

Then, you have 2 possible defense lines (ideally you should combine both)

reduce the exposition risk

ensure that the web application stack is consistenly patched
ensure that the web application is hidden behind a reverse proxy: this can help to ensure that only HTTP requests to acceptable URLs can reach the server - the URL rewriting of the proxy can map incoming URLs to a subpath to guarantee that no URL at root can be received
ensure the datacenter is correctly protected behind a firewall and all servers follow best practice rules (limited admin accesses, only required ports open, etc.)

reduce the possible consequences of a successful attack

setup log analyzis to detect illicit access and reduce to time window of an attack
If the attacker could read the environment variable - but cannot execute any command - ensure that the database server is not reachable from the outside of the datacenter
if the data is highly sensitive, you can even protect access to the database even if the web application server was compromised by using an API requiring a previous client authentication and pass the client token to a service appplication server that can do authorization controls. The full defense becomes here:

external_firewall - reverse_proxy - web_server - internal_firewal- application_server

Encryption on the server can only be obfuscation, because the decryption key must be accessible somewhere. It can only harden the task for the attacker, but will not be able to block him.


Is Clickjacking a real security vulnerability? As I understand it, this is how an attacker would exploit clickjacking:

Create a new website malicioussite.com which includes my site in a frame, but overlays malicious input fields or buttons over the HTML elements of my site.
Send out phishing emails to get users to click on the link that goes to malicioussite.com rather than my site (or use some other technique to distribute the phishing link).
Users enter data into or click on the malicious elements.
Profit

Savvy users would either not click the link, or notice that the address bar is incorrect.  However, plenty of people would probably not notice.

My question is this: Can't the attacker achieve the same thing by using malicioussite.com as a reverse proxy?  All the steps above would be the same, except that malicioussite.com would forward the requests to my site and then insert an extra <script> tag in the HTML response to run the malicious code and add the malicious HTML elements.  The X-FRAME-OPTIONS header wouldn't help in that case because there are no frames (and the reverse proxy can strip it out anyway).

The attack relies on the user not checking the address bar, so if the attacker can implement the same attack in a different way that can't be defeated, why bother with X-FRAME-OPTIONS or other clickjacking protections?

This is a very interesting question.

First of all, let's start with your scenario: A user visiting website www.evil.com which is a reverse proxy that loads www.good.com and modifies its content. Congratulations! You've just re-invented a classic MiTM attack, but a very poor one. Visiting evil.com means that your browser won't send good.com cookies, which means that your reverse proxy won't be able to act on behalf of the user. To fix this, now you'll have to trick the user into logging in to your reverse proxy with his good.com. Congratulations! You've re-invented an attack with a fake landing page.

The scenario you're describing has nothing to do with clickjacking, and we actually employ clickjacking protection for a very different reason: With clickjacking, an attacker would trick an authenticated user into performing some action. Even if the user is visiting evil.com, unlike your proposed scenario with a reverse proxy, his request is still sent to good.com along with the cookies containing his session ID. Thus, the action will be performed within the authenticated user's session.

Does that sound familiar? Yes it does, because that's how a CSRF attack works, but the only difference is that, with CSRF, the action is performed programatically.. except for one little thing: Clickjacking defeats anti-CSRF mechanisms. With clickjacking, the action is performed within the user's browser, by the user himself, and inside the legitimate page (loaded within iFrame).

So, in short: Your proposed attack is indeed plausible, but we use anti-clickjacking to defeat completely different attacks. For that, yes, clickjacking is indeed a real, distinct security concern.


Apple device management Not sure if this has been answered but I cannot find anything via the search. The whole company (10 people) use Apple devices but aren't all in the same office. Are there any tools that I can use to administer (updates, password policy, asset register) all these devices?

I was pretty sure osx server used to do this but I'm not sure if Apple are still maintaining it.

The terms you're looking for are Mobile Device Management (MDM) or Enterprise Mobility Management (EMM)

There are many vendors.  Security.SE isn't a vendor recommendation site, but one option is Cisco's Meraki System Manager - they are free for under 100 devices and can handle a mix of iOS, Windows, Android, MacOS.  Disclaimer : I have no relationship with Cisco other than using their services/products.


Can I decrypt a DiskCryptor-encrypted hard drive using Veracrypt? I have a hardrive I encrypted with DiskCryptor back when I was using Windows. Now that I have Linux I want to decrypt the hard drive but it turned out DiskCryptor is not available for Linux, whereas Veracrypt is. So I have two ideas:

1) Try to decrypt the hard drive on my Linux machine using Veracrypt.

2) Alternatively, use Wine to run DiskCryptor and use it to decrypt the hard drive.

If neither of the options are possible, I will use another Windows machine but I don't have one myself so that's why I'm asking.

VeraCrypt documentation web pages (https://veracrypt.codeplex.com/documentation) do not say DiskCryptor and VeraCrypt are compatible!  And the web pages do not say we can convert a DiskCryptor volume to a VeraCrypt volume.  A TrueCrypt volume is ok, though.

If VercaCrypt cannot mount the hard drive, it cannot decrypt it.  I doubt VeraCrypt program will mess up with the hard drive.  But I will not risk to try to do that if the hard drive does not have any backup and the data in the hard drive are really important.


Protect app from Http Proxy like Charles I am using https request for web API in my app. But I know Charles allowed to access https request also, via install root certificates on device. So, someone downloaded the app from PlayStore and installed root certificates on his device and got my Web API.

So, Please give me advice how i can protect my WebAPI.

You can't.

You can explicitly check the certificate used in your app.This will make it harder for anyone to use a MITM proxy. But if the app is running on the device of the attacker, they can change the code and allow their own certificate.


What does the attached php malware do? Found this on a WordPress server under the filename wp-includes/class-wp-image-editor-fd.php when WordFence picked it up as being an unexpected file.

Link to source is here: https://pastebin.com/DWe4d33K

Very clearly looks like malware due to the classic obfuscation.
VirusTotal gave me no detections: https://www.virustotal.com/gui/file/bac2bb4d0dac58e5563b47e6e63f3b332caba11da065861269e87ebc249f34e9/detection

I tried using deobfuscation tools to no avail. This isn't really more forte so I'm hoping someone with more experience can help me figure out what this code does and how it might have been triggered by an attacker.

All help is very much appreciated as it'll be huge for understanding what kind of access may have been gained.

I did this myself. By essentially replacing eval's with echo's I was able to peel away enough layers until I reached the ugly webshell underneath. Appears to be the FilesMan webshell. This blog post matches the code I'm seeing pretty well: http://blog.codeguard.com/malwaregone-threat-analysis-wso-filesman-backdoor/


How can I verify that a root certificate is authentic? I have found that my home PC (Windows 10) currently has 39 root certificates installed.

While scrolling though the list I have noticed:

Names that look familiar (e.g. Thawte / VeriSign)
Names that are unfamiliar to me (e.g. Startcom / Entrust)
Expiry dates in the future (e.g. 2020-12-31 / 2030-01-01)
Expiry dates in the past (e.g.  1999-12-31 / 2004-01-08)

All of this a a bit concerning and I would like to do more to control the situation. To start with I would like to confirm their legitimacy.

How can I verify that a root certificate is authentic?

How can I verify that a root certificate is authentic?

Authenticity can be kind of checked if you search for the fingerprint online and find the certificate where you would expect it. But this is not foolproof because this might be a fake site which is just looking good and has a trustable host name. In any case you don't know the party personally and authenticity does not mean that the party can be trusted.

At the end you have to trust the vendor of your OS or browser that it is doing the right thing, because effectively you have no way to really verify it. But this kind of trust is not uncommon, i.e. you trust your supermarket that the food is edible and not expired or even poisoned, you trust your gas station that the gasoline is not dangerous for your car ... - i.e. you already trust others in security issues. And you hope that if this trust is no longer justified you will somehow be notified.

Trust can go wrong as can be seen in the Superfish affair where one trusted the vendor (Lenovo) to ship a trustable computer. But this computer contained a software to injects ads and additionally the software installed its own root certificate to man-in-the-middle connections in order to inject ads into https traffic too. This certificate was definitely authentic, but most people would not consider it trustable.


How to store secret key used for hashing? I am trying to figure out a secure way to store secret keys used in the hashing of social security numbers.

The idea is for de-identification of research subjects yet still permitting follow-ups over time by hashing a secret key concatenated with the SSN and using that as the unique identifier.

The steps I conceived of is the following:

At time 0, when data on subject A is collected, randomly generate a secret key and concatenate it with the SSN before hashing it.
Replace the SSN with the hash value. This de-identified record will be used for research purposes.
Store the SSN and generated secret key somehow.
At time 1, when further data of subject A is collected, we want to append this new data to the data collected previously. Search for the secret key using the SSN and then hashing again to get the required hash value.

I am struggling in Step 3 and looking for best practices in such a scenario. It seems that if I were to just store the SSN together with the secret key in a text file then the risk for reidentification is high once the intruder gets access of the file.

Any help is greatly appreciated!

All I can think of is....

1) Use a lookup table to map SSNs to salts (or random identifiers for the persistent anonymized data) but keep this a long way away from the persistent, anonmyzed data. Both the datasets need to be compromised to resolve the data.

2) as per 1 but key the random value/random salt by a hash of the SSN (and keep the lookup table seperate). This adds some Security value over 1, but not a lot. Both datasets need to be compromized for the data to be resolved.

3) as per 2 but hash the SSN key using a static salt (i.e. storing hash($ssn, "staticsalt")->secret). Ideally keep the satic salt somewhere other than the 2 existing data stores. Once again this only adds a little Security value

4) use other information about the subject (if available) to increase the amount of entropy in the data used to create the hash. This would make it more difficult to deanonymize the data but doesn't impact the ability to find an individual in the dataset if their details are known.


Difference between SSL connection and SSL session What is the difference between SSL connection and SSL session?

This is what my lecture notes have to say which makes no sense to me (I am new to SSL):

  SSL Connection:

  A transient peer-to-peer communications link.
  Each connection is associated with one SSL session.

  SSL Session:

  A session is an association between client and server.
  It is created by the Handshake Protocol.
  It defines a set of security parameters.
  It may be shared by multiple SSL connections.
  It is useful to avoid expensive negotiations of security parameters for each connection.  Single session has many connections.
  Every connection has a different key

I tried googling it but the results didn't bring up anything useful.

The only thing I know is that a single SSL session can have multiple SSL connections.

Can someone explain to me in simple terms what the differences are?

In General:

A connection is a communication channel between a client and a server. For example: a TCP socket. Connections are usually short lived and servers are usually configured to timeout a connection if it is left idle for too long.

A session is a way of maintaining state on the server side. You can think of it as a memory chunk allocated on the server and this memory chunk is associated with a connection. Even if a connection dies, you can resume a session (using cookies in case of HTTP protocol).

You can read more about it in this whitepaper.

In context of SSL:

The same applies for SSL/TLS and for any other protocol. This is very well explained, in simple terms, in one of the results when you google it. Here you go:

  Difference between connection and session is that connection is a live
  communication channel, and session is a set of negotiated cryptography
  parameters.

  You can close connection, but keep session, even store it to disk, and
  subsequently resume it using another connection, may be in completely
  different process, or even after system reboot (of course, stored
  session should be kept both on the client and on the server).

  On other hand, you can renegotiate TLS parameters and create entirely
  new session without interrupting connection.


Encrypt Android app data and send to web service I want to develop an Android app that may contain sensitive personally identifying information (national ID number, phone number, etc.) among other data that will be stored in an Android phone.

Let's say that this data will be kept on the phone, which is offline most of the time, and has a very small and not so frequent time-window to send the data to a remote server.

I want to secure (encrypt?) this data so that in a situation where the phone is stolen, someone with tech knowledge cannot root the phone, access the app storage and access the information.

The data doesn't need to be decrypted on the phone, so it can be sent encrypted to the server, but the server needs to be able to decrypt it there.

What are the options here? Are certificates or public/private keys suitable for this, or they are too faulty?

What are the advantages and disadvantages of each solution?

Public / private keys seems the logical way to do, but you may not want to code from scratch.

Look at how TextSecure does it: https://github.com/WhisperSystems/TextSecure/

It does all the things that your app would (encrypt data / send to web service).

You should probably use the encryption libraries / code directly from their codebase although the license (GPLv3) may be restrictive depending on your use case.


Recommendations for Changing the Default Shell For Service Accounts It seems as if most Linux systems use either /sbin/nologin or /bin/false as the default shell for service accounts. Many hardening guides, such as CIS benchmarks, recommend changing the default shell for these accounts to /dev/null. While many recommendations have an anslysis attached, this is one that I have never seen justified. What concerns are driving this recommendations and what threat it is attempting to mitigate?

The only true technical reason I'm aware of is the possibility of malicious file substitution.  Consider an attacker who finds a way to write to arbitrary files.  If they can overwrite /sbin/nologin or /bin/false with a copy of /bin/bash, then they can conceivably find a way to log in as a service user and continue to elevate their privilege from there.

However, /dev/null cannot be trivially replaced in such a manner, for various reasons:

It's a device, not a flat file
Anything written to it disappears, so a simple overwrite won't work
If someone did replace it with /bin/bash, it might then in turn be overwritten by one of the many programs that use /dev/null as a bit sink, thwarting the attacker
If someone did replace it, it could break some system functionality in a way that will alert the administrators that something is wrong, much more so than replacing 'nologin' or even 'false'.

There is also a non-technical reason, which is that many administrators are bound by tradition and/or the habits they learned long ago, and /dev/null was once a more common choice for this use (I'm pretty sure /sbin/nologin didn't exist 20 years ago).  Make of that what you will.


How to you prevent accidental data/document leakage in a byod world? As an employee in one of the now endless tech organisations that promote BYOD mobile and laptop devices, or devices in general that can be taken home and or used off premise, how do you prevent accidental data leakage/enforce document destruction in your security policies?

Specific examples of risks I think of are:

Commerically confidential document is downloaded to device from email, forgotten and backed up by user, later restored to another device/multiple devices and eventually migrates into the users personal documents in the cloud/external hard drive essentially forever lasting. User practices poor cloud security/loses hard drive and document is released into the wild.
Document A is a policy to follow when doing x,y,z procedures inside the organisation. User A spreads the document to 30 people via email and each user downloads the document. Document A becomes obsolete due to security risk in policy. Document B is released, but users keep using Document A.

I feel as if a security policy alone can not really enforce this behavior as its human error for mis use. Is it unreasonable to make sure documents live in a cloud based environment with correct classification policies and can never be downloaded? e.g utilising a service such as Google Drive or a document management system where you can upload, or edit live but not download.

I feel as if this risk is much less with a traditional client/server setup where essentially the files are owned by the server and the users do not take the devices home. Policies and clean ups on user files are much easier when they all live in a single location. Auditing can occur on things like backing up files to USB etc for malicious use, but I guess i'm more concerned about the accidental side of things.

Thoughts?

Your question is a bit of a jumble but actually asks about a core problem. It's about authorisation.

Who and what is authorised to download/read a document in a cloud world and how do you enforce it?

Policies define a direction and goal. They guide the design of the authorisation process and enforcement mechanisms. In short, they are only a starting point. Ensuring limits on distribution (email, in your example) and version control (policy versions, in your example) need to be enforced through technology.

From a technology perspective, there have been many attempts to address this.

Blackberry and Samsung Knox (full disclosure, I was part of the Knox advisory team) had sandbox areas of the device that could be authorised to connect and allowed the org to control that part of the device. As you probably know, this saw limited success.

But what about BYOD? This, unfortunately, only has a single solution: do not authorise devices to access data that is not under the org's control. Either issue devices to users or ask their consent to install an agent on the device. This is the only way to address this problem in any efficient way.

What about BYOEmail? This is addressed by simply monitoring and auditing emails to webmail addresses. Anything to an employee's personal email account should be barred via policy and followed up on during audits. This addresses your 'accidental' side of things. But, this requires that you maintain your own email systems and have people and mechanisms to perform this level of monitoring.

Yes, BYOD and cloud make it possible for a 5-person team to do the work of a 50-person team, but what's lost in that efficiency is the control over the team's data, and that's what no one talks about. The leap from 'agile' to 'secure' is a big leap ...


Session fixation attack, cookie based sessions over https A third party security consultant did a Penetration test few of our webapps. One of the findings was a potential session fixation vulnerability.

We have several webapps all Java with single sign on provided by JASIG CAS. To briefly summarize CAS workflow -- when a new request comes to webapp(service in CAS terminology) it redirects to preset CAS url. If the user is not already authenticated, it presents a login form and upon successful redirects the browser back to the service with a token. In case the user is already authenticated, it immediately redirects back to service with a token.

The aforementioned vulnerability stems from the fact that the service in question sets the session cookie (named JSESSIONID) when it is redirecting to CAS ie before authentication AND continues to use it after redirect. The claim is since same session id is used before and after authentication it is open to session fixation types of attack.

Given that all services and CAS are working exclusively over https and session cookie is secure, http only and generated at server, is there any way session fixation may be a threat here ?

For every session fixation vulnerability the attacker must know the session identifier. There two ways to ways to obtain it – by stealing it from victim’s PC and through brute-force attack.

Httponly attribute protects your cookie against XSS attacks using browser same-origin policy, but there are many other ways to access victim’s PC and steal the cookie, including vulnerability exploitation in victim's browser.

Unfortunately I’m not familiar with CAS and do now know for how long the session id is kept unchanged. If your server keeps using the same session id for a significant amount of time, then it is possible to brute-force/predict it. This is where the session fixation becomes dangerous.

My advice is to generate new session token every 15-20 minutes for active sessions as well. This way it will be extremely hard to brute-forced it and your application will be protected against session fixation attacks.


Is this version of openssl vulnerable? I have an old Debian 3.1 (kernel 2.4.19) where the version of ssl is

$ openssl version
OpenSSL 0.9.8c 05 Sep 2006

I read that there was some issue about random generator being guessable.

https://www.debian.org/security/2008/dsa-1571

But then it seems that the version I use is not vulnerable because it is just before the change. Or is there a way to verify this? Should I try and upgrade OpenSSL regardless of it being vulnerable or not?

Probably vulnerable.
CVEDetails has a list of 49 vulnerabilities for that version.
Take your pick.
Also: Debian 3.1 has had no security updates for nine years.


Is it possible to read the response of HTTP request without XHR? I am testing an application, and come across a GET request that returns sensitive info in the response body. (CSRF token to be validated for next request). Since it is a GET request, developer skipped CSRF protection for all the GET requests and only applied to POST or state changing requests. That token will be used for next POST request.

I know using XHR we can accomplish this, but IF CORS is not enabled, or allowed only for particular domain, is it still possible to perform CSRF in such case without XHR?

Depending on what the response looks like, you might in some rare cases be able to use a XSSI attack (Cross Site Script Include). That means, if the response represents a valid JavaScript statement (that includes the sensitive info), you could simply create a page that imports that script and than read it in some way with a different script. That works because the SoP does not prevent you to create a script tag and import a script from a different domain. An example attack can be found here:

http://blog.intothesymmetry.com/2017/05/cross-origin-brute-forcing-of-saml-and.html


Is thread's auto-login from email implementation secure/good user experience? As far as I can tell thread.com log their users in automatically based on a token in their emails, appended to the URL.

e.g https://www.thread.com/1234logmeintomyaccount-forexample

This is a really useful, great feature and makes it very easy to interact with the site without having to remember/sign in all the time.

However, they also save credit card and address details for easy checkout.

So, unless I'm missing something, if a user forwarded one of their emails to someone and say that got forwarded on again, anyone could log into their account, see their personal information and mess with their money.
You could also find the URL in a browser's history and access it there.

Is it me or is this a massive security flaw and, if the worst happens, therefore a terrible user experience.
The benefits are brilliant but the potential risks seem to far outweigh those benefits.

If I have missed something and this is done securely, how are they doing it?

https://www.thread.com

In my perspective it's probably approximately the same level of security as allowing you to reset your password with only using an email address. Essentially, if you can request a password reset to be sent to you in an email, and one click later you set a new one, it's the same thing.

Now, forwarding such an email contains the same security risks in both scenarios, but honestly, when was the last time you forwarded a password reset email to your friend? In the same way, why would you forward a login email to someone else but yourself?

Also, despite being in the browser's history the link should usually only single-use (i.e. can't use an email from decades ago to reset your password, you have to create a new request). Similarly, when clicking an auto-logon link, the server gives you a cookie and deletes the url token from its side, effectively disabling you from using it twice from two different computers.

Of course, I haven't tested this at all, so it should be taken with salt, but hopefully this is all reasonable enough.


Is phpseclib a secure and reliable alternative to OpenSSL? I know that OpenSSL needs to be installed and activated via apache and the config files, which can be cumbersome or even impossible, and that phpseclib is more flexible and easier to handle than OpenSSL (X.509 problem/ in certain situations the PHP implementation of OpenSSL needs a X.509 certificate in order to create a valid keypair), so i'd like to use phpseclib instead of OpenSSL.

BUT, and this is the question, is it really a viable alternative securitywise? Isn't it problematic to have its source code lying around on the server? Are there some negative secucity implications using phpseclib, or any php implementation of RSA for that matter?

Situation:

OpenSSL: +native +binary -less flexible -less versatile -sometimes config problems
phpseclib: +flexible +portable +more versatile -non native -not compiled

Question:

Security?

EDIT:
I use OpenSSL to create a keypair and then encrypt data directly to the DB (client request, no way around it). But the question here is a general one, independent of the final application.

Implementing cryptographic algorithms securely is hard. I should know. Cryptographic algorithms concentrate secrets into keys, which thus are very valuable, and a lot of implementation-related leaks (e.g. small variations of execution time) can become disastrous when applied to cryptography.

There are ways to avoid such leaks, but they require care, a lot of trial-and-error, and, above all else, extensive knowledge of the low-level behaviour of the execution engine. As a rule, the farther you are from the hardware, the harder it gets to secure the code against side-channel attacks. PHP is much further from the metal than C code.

Now I don't say that it is not possible; for instance, a timing-attack resistant implementation of a cryptographic algorithm is quite possible in Java or .NET. So it should be doable in PHP as well. But, as usual, it will require a lot of external scrutiny to ascertain.

Remember that new is bad in cryptography; security is gained through prolonged exposure. For all its shortcomings, OpenSSL has had a lot of exposure over the years. phpseclib is newer, and uses a "somewhat hostile" framework when it comes to side-channel leaks, so it is much too early to declare it fit for production.

I don't know what you mean by "X.509 problem". I mean, X.509 is a spawn of Hell; but I don't see how an implementation in PHP would fare better. The one good point of PHP here is that PHP has checks on array bounds, thus limiting the consequences of buffer overflows (application crash instead of actually overflowing the buffer); this matters for X.509 only because it seems that many people are incapable of implementing ASN.1 encoding/decoding properly, without tripping on these buffers. But apart from that, the complexity of X.509 is unchanged, whether it uses C or PHP.

The idea of rewriting everything from scratch, "for simplicity", arises regularly when talking about X.509. But the "problem" of X.509 is not that usual implementations are bad; it is that X.509 is inherently complex, because it tries to deal upfront with the complex issue of trust delegation (all competing solutions just try to side-step it); and X.509 (the standard) has accumulated a lot of legacy crud. Rewriting it from scratch won't make it simpler, unless you remove the parts of the standard which you don't like, in which case it will be simpler, but it won't work.


How much information about our Security & Penetration Testing should we share with customers? We have a B2B Saas service which runs on Microsoft Azure. Microsoft publishes a lot of information about Azure security but occasionally customers ask us about the security testing and audits that have been performed on our own software - rather than Microsoft’s platform generally.

What good practice should we follow here? Is it enough to say we regularly have our systems tested by certified independent specialists? Or should we provide more detail - if so to what level?

This will vary according to your business and the transparency you have with your customers. Most of the companies perform tests on their application and share with the customers the standards they have been tested against, but not the "step-by-step" of the testing.

For example, let's say you have a web application, you can mention to your customers that your application was tested against the OWASP web application standards. That should be enough to satisfy most of the customers.

If you deal with sensitive information, you may need to get certified in some regulations. For example, if you deal with credit card information, you need to be PCI-Certified. Once you get this certification, you just need to proof to your clients that you passed on PCI, but you don't necessarily need to describe every single test that was done.


Hiding user account names from unauthenticated RDP sessions This is for a Windows 7 Ultimate system, which is not a member of a domain.

When I log into the system locally, I am required to either manually enter my user ID or authenticate with biometrics.  The system does not display my username on the Welcome screen at boot-up, or when the session is locked.

In order for this to work, I've made the following configurations in secpol.msc, under Security Settings\Local Policies\Security Options:

Interactive logon: Display user information when the session is locked

Do not display user information.

Interactive logon: Do not display last username

Enabled

Interactive logon: Do not require CTRL+ALT+DEL

Disabled

This works wonderfully for logons at the console.  However, RDP sessions still display the regular "Welcome" screen with all users listed.

How can I configure the system so that the remote login screen does not leak user account details?

When you say "Welcome" screen with all users listed. Is that so, or is it one named user and then  "Other user"?

If it is one named user and "Other user" then the named user is actually coming from the RDP client and is not being exposed. Depending on which client you are connecting with, but at least the Win XP client will save last connected user on the client side (even if the Allow me to save credentials is not ticked). My current Win 7 and Win 2008 RDP clients will authenticate before connecting (so you never see the login screen at all).

If my observation fits, you can prove it by entering a non-account on the client side without password, and it will still be displayed.


When generating PKI key pair with a smart card, who decides if the key is exportable? I'm in the process of obtaining a code signing certificate from a CA that requires the use of a smart card for the generation of the PKI key pair.
However, I would like to be in the possession of the private key, and not depend on a physical device.

So here comes the question, who decides if the private key is exportable, the smart card software implementation, or the requester (CA)? I was thinking maybe I could acquire a smart card that allows for such a thing.

I ask this because I'm trying to figure out a way to get in the possession of my own private key, in the event PKCS #11 is not suitable in the future. I don't need PKCS #11 security.

The whole point of a smart card is that they private key is protected against extraction. There are ways to create the private key outside of the smart card and then import it into it in which case you have a backup.  But in your case the requirement is that the key has to be generated on the card itself which means it can only be used with the card.

  ... requires the use of a smart card for the generation of the PKI key pair. However, I would like to be in the possession of the private key, and not depend on a physical device... I don't need PKCS #11 security.

It does not matter what you want or what you feel you need. The CA decided that the certificates it issues need to be properly protected against misuse. It regularly happens that code signing keys gets stolen and misused to sign and spread malware and having the key only on a smart card is a good protection against this.

  ...  in the event PKCS #11 is not suitable in the future

PKCS#11 is an established standard and widely used. It is likely that your code signing certificate is long expired before PKCS#11 becomes obsolete.


Containerization vs. Chroot in shared hosting Forgive my rudimentary understanding of server security, but one thing I've always struggled with was understanding how to setup chroot to separate folders (which are discrete WP installations) in a /var/www directory. There is a lot of conflicting information I've seen that states Apache doesn't support it in virtual hosts, etc. though some seem to recommend it anyway. Generally, I've been confused about how to proceed. I don't want a compromised plugin or WP login from one site allowing attacking scripts access to the larger file system and other websites.

So, at some point I saw a talk on WP development with Docker. It does offer up a lot of workflow advantages, but it would also required we completely rejig our setup. Does containerization help eliminate the need for a chroot type solution? Does it effectively jail anything (other than exposed ports, I guess) to within its own container? If a single container (and only that single container) was compromised by a malicious script or brute force attack, it is easy enough to spin up a replacement... this isn't mean to be a comprehensive security question as I know using Docker isn't the same as "hardening", but what I'm really wondering is:

  In a shared Ubuntu hosting environment, would Docker's containerization help prevent a compromised WordPress site from spreading vs. having them all in /var/www with some sort of chroot solution?

First, chroot is not a security feature in any Unix systems. A privileged user can perform a second chroot to break out. See here

In a docker environment, processes and network are isolated so can't try to read kernel memory or use more RAM than allowed thanks to namespaces. Indeed, if any user inside a container is able to escape it using some sort of kernel exploit, it will be a user with the docker engine privileges so it will have access to all of them in the host machine but in that scenarios with chroot all is more easy.
Therefore, Docker in general is more secure than a chroot configuration because chroot is meant as a tool for isolating processes for installation, debugging, and legacy library usage.

Secondly, a Wordpress core can start clean every time you start the container but in chroot, writes are permanent. Also, It is possible for the containers to even lack a shell so if someone upload a phpshell it will fail.

More info: Can I make my online server more secure using Docker?


What are the consequences of disabling ssl v2 and weak ciphers? It is my understanding that IIS has ssl v2 enabled by default.  Also, TLS 1.0, if enabled, allows for at least one known major vulnerability titled "beast attack".

If the weak and vulnerable ciphers are disabled from the server is there known cons from application or users perspective?

Disabling weaker ciphers on the server can prevent older browsers connecting - which is the main reason this sort of thing is not kept as up to date as security teams would like.

Encouraging organisations to update browsers, and to require their customers to upgrade, is good practice and helps remove outdated versions and ciphers.


Is there any good reason to choose IDS over IPS? As far as I know,

IDS sniffs network traffic, and if intrusion is detected, reports it.

And IPS sniffs network traffic, and if intrusion is detected, rejects it, and reports why it was blocked. Am I right?

And I read that some IPS can even be configured not to drop packets, just to report them.

Apart from the ability to analyze the intrusion and take action myself, is there any other good reason to choose IDS over IPS? Maybe the price tag?

Passively listening to network traffic to detecting suspicious behavior is still important. There are only a few obvious attacks which you might detect and block immediately but there is lots of traffic which only looks a bit suspicious or even innocent. But, if you collect traffic information over some time and maybe from multiple places in your network, you might see a pattern in this innocent traffic which points to anomalies or attacks which try to be stealth (like APT).

Apart from that, the meaning of words like IDS, IPS or firewall is not clearly defined and they are mostly replaced today by even more blurry marketing speech like "next generation firewall" or "unified threat management". The classical IDS products like snort, bro and suricata still exist and are in active development, but they are mostly integrated in UTM or NGFW solutions or things with different marketing names.


Do concurrent connections to an HTTPS website perform separate SSL handshakes? I know that most browsers nowadays support around 6 concurrent TCP sessions per hostname, to perform multiple requests at the same time.

For sites which utilise SSL, is there a separate handshake performed for each TCP session, or is a single SSL handshake performed, with the resulting symmetric key being reused for each concurrent TCP session?

Each new connection does a separate TCP handshake and a separate TLS handshake. But if there is an existing SSL session they will try to reuse it, so all but the first connection to a server only do an abbreviated handshake if the server supports session reuse. In case of session reuse no key exchange is performed, that is the same symmetric key is re-used. See also How does SSL/TLS work?.


What is a good XSS vector without forward slashes and spaces? I need an XSS vector that doesn't use forward slashes nor spaces. I've gone through lists of hundreds of vectors, but they usually have one of those two. The space gets URL encoded, and anything after a slash gets deleted.

I've tried things such as <script\src=*>, but you'd need a forward slash to make it work from my understanding.

No space, no slash:
<svg•onload=alert(1)>

The • above should be a form feed character (0x0c), but SE does not allow it in posts. See how it runs here.


Which is safer, GSM or CDMA? I have read in the past (no sure where) that unfortunately there exist illegal devices that permit crooks to eavesdrop on GSM mobile phone conversations. I recently also heard that some people had created a spoofed cell phone tower for GSM. My question is, if I switch over to using a CDMA phone, would I be any safer? I don't really want to give up the sweet deal that I have with XYZ mobile phone company, but if I must then I will.

CDMA uses the CAVE algorithm for authentication, CMEA for privacy and and ORYX for integrity. But these algorithms are all prone to cryptographic attacks similar to those conducted on GSM. So, don't depend too much on the encryption provided by CDMA too since 'attacks only get better, they never get worse' - Bruce Schneier.


How to prevent Cookie-Bombs? Egor Homakov made a nice writeup (Cookie Bomb or let's break the Internet) on how to crash CDNs and other websites with cookies.

Although this is a user/browser-side DOS, I'm wondering how one would stop this on the server-side.

Most browsers have a limit on how many cookies they'll store for a single TLD.  So, if the server is configured to allow a sufficiently large request to include all these cookies, the requests won't be rejected anymore.  Apache has options like LimitRequestFields, LimitRequestFieldSize, etc.  Setting these sufficiently high should allow the request to be processed with all the attacker-added cookies, though at a memory and processing time cost.

Of course, if you control the entire domain, there's other mitigations possible,
since it requires that an attacker is able to author content that sets cookies on *.targetdomain.com, it is only possible to exploit with attacker-controlled content on that domain.  So if attackers are not allowed to create server-side scripts (i.e., anything that can send Set-Cookie) or craft JavaScript (that can set cookies via document.cookie) then you'd be vulnerable.  So clearly, the mitigation is not allowing users to create content on those domains.


Bypass Asp.Net 4.6 "A potentially dangerous Request.QueryString value was detected from the client" I'm testing an application where the application does not handle special characters but request validation in ASP.NET picks it up and throws an exception.

There have been some different ways to bypass this previously like these links show:

http://www.procheckup.com/media/39734/bypassing-dot-net-validaterequest.pdf

https://infosecauditor.wordpress.com/2013/05/27/bypassing-asp-net-validaterequest-for-script-injection-attacks/

http://blog.diniscruz.com/2014/06/bypassing-aspnet-request-validation.html

https://www.whitehatsec.com/blog/by-the-website-vuln-numbers-net-xss-request-validation-bypass/

Is there anything newer that I have missed? The value passed into the q-parameter is printed inside an

 tag without any encoding.

  Description: ASP.NET has detected data in the request that is
  potentially dangerous because it might include HTML markup or script.
  The data might represent an attempt to compromise the security of your
  application, such as a cross-site scripting attack. If this type of
  input is appropriate in your application, you can include code in a
  web page to explicitly allow it. For more information, see
  http://go.microsoft.com/fwlink/?LinkID=212874.

  Exception Details: System.Web.HttpRequestValidationException: A
  potentially dangerous Request.QueryString value was detected from the
  client (q="<img").

Version:

  Version Information: Microsoft .NET Framework Version:4.0.30319;
  ASP.NET Version:4.6.1087.0

As long as a standard charset is being used, there is no known publicly available way to exploit this in HTML context for any common browsers. Source: A lot of research and experience.


Layer7 DDoS Protection vs WAF, which should I use? I have Layer3 ddos protection, but I want to upgrade it to Layer7 ddos protection. But when i look about Layer7 Ddos attacks, I see that they are usually HTTP/HTTPS based attacks. I have 3 questions;

What is other Layer7 DDos attacks, e.g FTP, DNS ?
If I use WAF instead of Layer7 ddos protection, what will be risks in my system?
Using WAF for ddos protection is a prefered way?

1.What is other Layer7 DDos attacks, e.g FTP, DNS ?

Application layer attacks or layer 7 (L7) DDoS attacks refer to a type
of malicious behavior designed to target the “top” layer in the OSI
model where common internet requests such as HTTP GET and HTTP POST
occur. These layer 7 attacks, in contrast to network layer attacks
such as DNS Amplification, are particularly effective due to their
consumption of server resources in addition to network resources.

2.If I use WAF instead of Layer7 ddos protection, what will be risks in my system?
WAF can mitigate ddos attack in under certain level. Application layer ddos attacks are very difficult to avoid. Specially bot net attacks are not spoofed and request seems to be fully legitimate.
3.Using WAF for ddos protection is a prefered way?
You have to use adaptive technology like a captcha code. Because botnet attacks are very difficult to identified from legitimate traffic therefore captcha will be best solution.
Web application Firewall also option. Please Read link.
(Details copied from cloudflare)


Recover data after multiple wipe I have a company laptop where I had many of my personal files and pictures. Now, I'm leaving for a new opportunity and I need to give them back the machine. So I used DBAN to wipe the hard drive.
I'm a bit paranoid so I wiped the HDD many times with DOD then DOD short. After that Quick and DOD short again and finally PRNG method.
I installed a new copy of Windows 10 at the end.
Assuming that some colleagues don't like me too much, is there in any chance that the IT team can recover my data from that drive by some kind of software or other ways?

It is very, very unlikely that they could recover data from the hard drive after even a single wipe.
But I would be more concerned about the data that is not on the drive, like your company cloud storage, email, backups, etc.


Assigning cPanel MySQL Privileges When I log into cPanel, I go to create a new MySQL Database with the wizard. Usually, it is recommended to assign the database user with all of the permissions from Insert, Update, Alter, Execute, etc. in the list. This has gotten me thinking.

Please note: When I build my applications, all the permissions that are required is Insert, Update, Delete, Select and Alter. Which is very reasonable for doing everything we want to displaying data, and interacting with it.

When do we ever want to actually allow an web application such as a simple PHP CRUD to execute, drop, create, trigger, and a few other privileges? Would that be more of a security threat to MySQL and our database?

It wouldn´t be more of a threat since using a high privileged account by itself won´t  give you any problem but it IS more of a risk if your application is somehow compromised by maybe a SQL Injection. It is recommended to run applications with just the level of privilege needed and not more, it is a security best practice known as the principle of least privilege.

http://en.wikipedia.org/wiki/Principle_of_least_privilege


Secure DHCP, DNS, Active Directory Server Are there any common vulnerabilities when creating a DHCP,DNS, and Active Directory server that should be addressed immediately?

The operating System is Windows Server 2012 R2 64-bit.

Well of course first and foremost is patching, obviously.   Make sure that you're up to date on all security patches, and this is a critical server to keep patched.

Second, perhaps also obviously, is to limit the server to only the services and open ports required for its specific duties.  Nothing extraneous should be running on this box.

Third, and perhaps most useful, is to review and apply the Microsoft Security Baselines for Windows Server 2012 R2 for the domain controller configuration.  This is going to help ensure that you're configuring the server in a reasonably optimally secure manner.


What can a hacker do when he has physical access to a system? I mean, I'm a tech guy here in my region (not a hacker...). When I sit in the front of another person's PC, I notice a little fear about what I can do in the system.

It's obvious that I will not compromise/steal/etc the system... One of my jobs is fix systems and I'm a "ethic guy" in that matter.

But I don't know the character, the ethics, of another tech guys that fix another PCs. Actually, a great parcel of my income is from customers that have problems on PC, send to another techies; that guys "fix" the PC, and some time after the customer is knocking my door, begging for help because the another guy "destroyed" the system.

But now, I'm curious. What a (previously prepared) hacker can do when get physical access to a system? I can think about 3 different "levels" of resources that an hacker can use in that situations, that will change what he will do:

He can possess a USB Drive with programs to compromise the system;
He has broadband internet access in the target system, and he can do a quick download of a program;
He has neither USB drives or internet access, so he will try compromise the system using some built-in operational system program or resource;

I know that the scope can be huge, so let's consider that the hacker will try ease the access from internet, so he will remote access the victm PC when he's in his home PC.

What he can do in that points? How do I to inspect the system about that kind of attack?

To focus on your individual cases:

Absolutely anything he wants. Malware, rootkits, backdoors, keyloggers, the whole shebang.
Again, absolutely anything. It's exactly the same as having the USB disk, because he can set up a site where he can download the files he needs, or just download them from existing sites.
Wipe the disk, delete system files, write batch files, modify system services, alter configuration, etc. The list is endless. There are a lot of malicious things you can do to a system without extra tools. It'd be trivial to write a VBScript to check the current date, compare it to a fixed value, then break the system if the dates match. Drop that into a run key and you've got instant repeat business.

In the first two cases, malware enables him to have full access to the box at any time. In the third case, it's still trivial. He could set up a hidden account on the machine, which he later uses for remote desktop. He could set up remote assist. Depending on which version of Windows the user is running, he could set up terminal services. He could even uninstall security patches to enable a remote code execution vulnerability, then exploit it from home. It's really not that difficult to make a machine like that remotely compromisable.


Possible sources of repeated Adware infections In the last couple of months I have had the same thing happen on separate occasions to two Android phones, a Mac laptop and a Windows desktop computer. In all cases, something infects Chrome making random words on all sites becomes links to advertising, advertising tabs appear at random or when I click the mouse.

To my knowledge, I have not visited any websites I would consider dodgy, nor downloaded any questionable apps or programs, opened email attachments, or anything else on any of the infected devices. I don’t know how it happened once, let alone 4 times.

I keep all machines patched, and they are not linked other than being on the same LAN and using the same Gmail account. Almost all programs I have downloaded for the laptop and desktop are for scientific computing or web development.

What sources might I have overlooked, and what can I do to stop this from happening?

Additional info:

Problem appears in Chrome only. I've checked Chrome extensions on PCs and all OK (do they even exist on Android)?
Nobody else who has used the same LAN as me has the problem
The problem appears intermittently on all devices - sometimes the same pages look OK and I can't find a pattern
I ran Avast on my Macbook which complained about FileZilla, which I deleted. Problem appears to be gone now on that machine, but was intermittent to begin with so not 100% convinced.

Screenshot from Android:

Using the same connection, phone and browser I now can't reproduce this screenshot, so it's definitely intermittent.

I have not visited any websites I would consider dodgy, nor downloaded
  dodgy apps or programs, opened email attachments, or anything else on
  any of the infected devices.

From the scenario you described, you seem to  be sure not to visit any web application that is likely to harm you.

There are two scenarii that may have been happened to you:

Nowadays, attackers have developed sofisticated methods: a simple visit to a given compromised webpage could lead to a drive-by download attack by exploiting your browser's vulnerabilities which are more frequently carried on by the extensions you install leading to spyware and adware (in the less dramatic cases) to infect your machine as it happened with visitors of Amnesty International's homepage on 2011 of which many users became victims.
Your LAN is compromised:

2.1. Modification of  home routers' DNS settings (Large-scale DNS redirection on home routers for financial theft).

2.2. Your router is infected somehow (Linksys Worm "TheMoon" Summary: What we know so far)

For the situation 2, you can be sure of that if your colleagues (or users of your LAN) have experienced the same issue as you. If so, you could ask an other question providing more information.

For the scenario 1, remove your exentions one by one to see which one could cause you the problem. But I do not think this will be too useful if an adware is already installed in your computer, but still it is a good thing to do because after removing them all you will need to run a full scan over your computer. Once your machines are cleaned, change your behavior for the future: for examplebefore making the decision to install any plugin to your browser, you need to be careful by checking the permissions requested by its developers, and when you visit a webpage prompting you a message to install a plugin to be able to view its content then do not hurry to follow the instructions (for example if you have already the Flash plugin installed and the page asks you to install it then this is likely to be a drive-by download attack requiring the user's interaction). And as a general safety practice, never install a plugin unless useful and install as few as possible of them and verify if you can the behavior and source code of your extensions from time to time as it is done here.


What are common security problems pen testers find? I am doing a study in school for computer science.  My research topic is pen testing, since that is what I hope to do after I graduate.  While doing research I am finding things that can go wrong, but I don't know how frequently each problem is encountered.

Edit:  I am very new to the subject so I hate to say my knowledge is limited.  The subjects that sound the most interesting to me are OS, networking, and social engineering (but I think that is a different can of worms.)

A general strategy and list of issues was spoken about in this thread -- https://security.stackexchange.com/a/68666/140

You should check out the MITRE CAPEC work. In 2015, colleagues and I have been seeing a lot of web-layer command injection or varietals of command injection, such as spoken about in Andrew Wilson's (of Bishop Fox) Toorcon talk, "if you like it then you shouldn't put a ring3 on it". For mobile apps: unobfuscated keys, static passwords, or other static configurables are common. When performing social engineering, the most common vector is local Administrator account privilege escalation to a Microsoft Forest and associated domains, as seen in Matt Weeks' (of root9b) talk at CanSecWest on "Credential Assessment: Mapping Privilege Escalation at Scale".

If you want to take a look under the hood, I recommend that you acquire the following toolchains:

For remote-command injection, get a license for Burp Suite Professional and leverage the metasploit-framework with tools such as sqlmap, NoSQLMap, commix, and liffy.
For mobile app penetration testing, check out the BLACKBUCK, idb, Lobotomy, and dtf toolsets, as well as Frida (and analogues or prerequisites to those such as adb, lldb, Xcode, usbmuxd, multcprelay, cycript, Drozer, Xposed framework, libimobiledevice, otool, optool, Android emulator strace, kdv, iosbinpack, et al).
For attacks against Microsoft Forests, be sure to check out the tools from Adaptive Red Team Tactics such as PowerSploit, Empire, Veil / PowerTools, ntlmv2_capture_hashcheck, root9b Orkos, FuzzLabs, Immunity Security ImmDbg, INNUENDO, CANVAS, and Cobalt Strike.


Understanding cross origing requests from a web page Reading up the XSS attacks on wiki I see that it says an injected script could send data/cookies to the attackers site. How is this achieved? Are there no checks/restrictions on cross origin requests like this from a browser? I thought the CORS spec was specifically done for this purpose and the original site must set the "helper" sites in the Access-Control-Allow-Origin header. Am I missing something or is it not needed? Can I just do a HTTP post to any server from any page?

EDIT: I think I answered my own question here. The injected script can fetch code from the attackers site thus making it run within the original site's code. That makes the attackers site ok to post to. Is this correct? Any other information welcome.

If you use CORS  for anything else then XMLHTTPRequest (which historically defaulted to only allow same origin) it has to be supported on the client side (browser) and it also has to explicitly used on the server side.

By default cross origin requests can be done simply be including an image, stylesheet, script etc from another site and if you have a successful XSS you can use it to send for example the session cookie inside such a request. To make this impossible you would need to check each request at the server side (e.g. requesting a same-site Origin or Referer and do not allow empty Origin/Referer) or limit cross-site requests at the client side (using Content-Security-Policy, not supported by all recent browsers).


What is a typical defense mechanism/setup against flooding back-end sql calls? I'm interested in figuring out what is a typical scenario of preventing the following attack scenario:

Back-end has as SQL server. Front end a simple "Hello World" HTML that passes an input (say user name) to be stored in SQL (sanitized). How does one typically prevent an attacker from writing a for loop and hammering the SQL with millions of store request until resources are exhausted? Like putting a cap on requests/second per IP?

P.S. Please part my ignorance - a desktop software developer trying to expand my borders :)
Thanks!

The database part of this is largely irrelevant, as a non-insignificant portion of your load will be on your web server rather than the database.

There are four common ways to implement rate limiting:

Perform rate checks against the user context, client IP, and other information within the application. This will allow more granular control of what types of requests you want to limit, and from who, but has the downside that the request must've already hit the web server and application in order for the checks to be performed.
Perform rate limiting on a host-based firewall, such as iptables. This allows you to reduce the load on your web application server daemon and any backend resources, but doesn't (trivially) allow you to make rules around which requests should be limited in different ways, as it operates at the transport layer (TCP/IP) rather than at the application layer (HTTP).
Install an appliance in front of the web server which performs deep packet inspection (DPI), or acts as a web application firewall (WAF). These are often called Layer 7 Firewalls or "full stack" firewalls, as they are designed to operate on application layer content (e.g. HTTP/HTTPS) as well as lower layers. You could argue that they fall under the umbrella term of Intrusion Prevention Systems (IPS), at least in terms of inline configuration. These can be very useful for terminating unwanted content before it even hits the target server, and can be very powerful, but have the downside that you usually have to put a lot of configuration work in, or buy an applicance.
Use a "security as a service" (SaaS) product in front of your server, which is designed to mitigate attacks such as flooding and DDoS. An example of this is CloudFlare. These aren't usually directly designed to prevent the exact types of attack you mentioned, but are pretty good at blackholing malicious automated traffic and DoS attacks.

These methods are not mutually exclusive; in fact, a combined approach is often the most effective.