How to check if a program is mining crypto in the background

This will depend on your skill and experience with understanding how applications work, along with how well the application is trying to hide its nefarious purposes.

At a very basic level, Cryptominers try to max out unused cycles, so you would expect to see your CPU/GPU pegging at max, so a first glance would suggest the app is not doing that.

However, it could be written to play nice, in which case you could check its behaviour and see if it changes when running a number of other applications or when idle - an intelligent coder may try to ramp up usage when you are away from the machine.

Or you could look at its storage space - what is the program doing with data?

Or better yet, what is it receiving or transmitting when it connects to the Internet, or what is it connecting to?

Or if you can, try reading the code to look for cryptomining code - the most popular ones may show up in a virus scan these days!


Can one find the value of a "constant salt" if they can set the password and get the hash?

An attacker that knows the password and the hash but not the pepper is in the same position as the attacker that knows the salt and hash, but not the password.

Putting in another way: hashedValue = hashFunction('thing attacker have', 'thing attacker does not have').

On the classic leaked database attack, the attacker knows the salt and the hash, not the password. On your case, he knows the password and the hash. Looks different, but it's exact the same. Nothing different at all.

Difficulty? It depends on the length of the pepper. If it's a 128 byte random string, is as difficult as bruteforcing a 128 byte random password.


Why are cryptographically secure random number generators required for shared keys?

As AndrolGenhald wrote in comment, modern protocols use Diffie Hellman (usually an Elliptic Curve Diffie Hellman) and don't use asymmetric encryption for key exchange.
The protocol often requires both sides to generate and send in the clear some random bytes. These can be "server random" and "client random" in the TLS handshake (and equivalent in SSH and IKEv2 for IPSec) but also nonces or IVs (CBC is not allowed in TLS 1.3 but bear with me). Basically, it is assumed that either side has used the same CSPRNG to generate data that was sent in the clear, before or after generating secret key material. If seeing the data that was sent in the clear allows a passive attacker to completely determine the inner state of the CSPRNG and then to "step" the CSPRNG forwards or backwards, the attacker gets the keys.

An illustrative example is the Juniper NSA backdoor. They had to exfiltrate some consecutive number of bytes from the CSPRNG to enable the passive attacker to compute the CSPRNG state to compute the secret keys. This necessitated multiple changes to the software in addition to the use of the backdoored PRNG. A non-cryptographic PRNG (like a Mersenne Twister) instead of a backdoored PRNG would be exploited in similar ways. Changes to how some of its output is sent in the clear will make exploitation easier or harder.


What are the pros and cons of a VPN for privacy

I have to say that in my opinion, VPN is very overrated in terms of privacy.

It's meant to tunnel your private data over an insecure medium, so provide confidentiality from your VPN client to your VPN server, and only between these points. The way from your application to your VPN client and the whole way from your VPN server to your wanted destionation does not include that! And it does not mean your destination won't know you're using VPN!

If you're an employee and need to do work in your companies network, fine, thats the purpose of VPN, but otherwise you have to distinguish your enemy:
Do you just want that one website you're visting to not know where you are? Maybe VPN is still ok.
Do you not want your authorities to know that, too? Hell don't even think about using VPN.
Your VPN provider will give out anything, and thats all you wanted to hide. He won't risk his business for you! No, even not if your providers country is different from yours. International "crime"-fighting is more organized than ever. And yes, downloading that one music title you'd never buy for money counts as "crime".

But you asked what you CAN do for privacy. There is something still exploitable to gain what you're seeking. Up to, I'd say 99% safety:

Prepaid mobile internet, it's cheap nowadays, and you can buy the SIM-card, the connector for your computer and the credit with the last anonymous payment method: Cash!
Of course you have to keep some important things in mind as to secure your computer (especially to not disclose information), just use it in crowded places, etc.

But as anything in security, the whole system is just as weak as the weakest member: One login with a real identity, one prepaid credit paid with your card, and you're (theoretically, but don't hope for something better) back to your current situation.


Mitigating security risks of using open-source software

How do you track and monitor vulnerabilities in open source software?

The same way it's monitored in closed source software. Vulnerabilities are reported and updated in subsequent releases. Generally this cycle is even faster with OSS.

What steps do you take to ensure that the open source software is risk free?

The same steps that are taken with closed source software: review, reputation, support. History demonstrates that closed source and open source have statistically similar risks.

To be fair closed source provides a target for legal action, but unless you have deep pockets that's not a winner.

This may or may not help your argument:

GSA Open Source Policy

  18F: An Open Source Team

  18F, a digital services delivery team within the General Services Administration, develops in-house digital solutions to help agencies meet the needs of the people and businesses they serve. This requires flexibility in how we code, with a focus on lowering costs for the American people, while improving their interactions with the U.S. Government.

  The default position of 18F when developing new projects is to:

  Use Free and Open Source Software (FOSS), which is software that does not charge users a purchase or licensing fee for modifying or redistributing the source code, in our projects and contribute back to the open source community.
  Develop our work in the open.
  Publish publicly all source code created or modified by 18F, whether developed in-house by government staff or through contracts negotiated by 18F.

Benefits

Flexible usage.
Community involvement.
Cost-savings.
Reusability.


Different usernames
What I think the reason for that is to avoid credentials reuse across multiple websites. While probably you are aware of how passwords should be unique, a large number of bank customer are people older than 60, which are kind and not aware of issues like that.
No Firstname Lastname Usernames
I believe is because they try to avoid phishing. In case a user's username is Bill Mat and his email address is billmat@gmail.com, you give a scammer a good base to create a better phishing email. And like I said previously, people who get scammed by this type of attacks are old people, who unluckily are easy victims.


Most secure is very subjective. Even Google's Captcha system has been known to be broken on ocassion, one example out of many. Treat Captcha as a speed bump to deter people from putting in a lot of effort to break it. Checkboxes if your speed bump is good enough is... maintained by a trusted company, regularly updated, and is useable. I know you said ignore usability, but the human factor cannot be ignored.


How can the content of a file refer to its own MD5?

'face2face' is only 9 characters, i.e. 36 bits since we are using hexadecimal encoding. It suffices to generate many pictures with some internal variations (subtle variations that do not impact the graphical output) and hash them all until the target string is obtained. Since we are looking for a 36-bit pattern and accept that pattern wherever it appears in the 32-character output (24 possible positions), then the average number of pictures to produce and hash will be about 236/24, i.e. about 2.8 billion. Since a basic desktop PC can compute several (many) million MD5 hashes per second, this should be done in less than an hour with some decently optimized code.

This has nothing to do with known weaknesses of MD5 with regards to collisions. The same could be done with SHA-1 or SHA-256.

This has already been discussed in this question.


Is it dangerous to allow customers to refer to fonts.googleapis.com in their scripts?

In theory, you're fine loading stylesheets and fonts from a third party - as you say, they're included in link tags, which shouldn't allow script execution. There are a few things which might cause information leakage though, and a potential for a targeted attack resulting in data appearing to change.

In terms of information leakage, browsers by default send a referer header when loading a resource. This will be sent to the font provider, and, if your links are structured in a way where you're attempting to use length or unknown values in the URL as a protection method, the font provider would be able to bypass that. If you're performing session checks, though, as most websites with authenticated sections in do, the third party shouldn't get the authentication tokens (usually cookies). Given that you're working in a sensitive industry, I'd hope this wasn't the case.

In terms of data appearing to change, a malicious font provider could supply fonts which are mapped incorrectly. Imagine if they supplied icons in a font, and you're using either a tick or a cross to indicate, for example, whether a blood sample was found to have a specific disease. By mapping the "tick" symbol to the "cross" value, and vice versa, an end user might think they've got some disease due to seeing this in the output. This would be a very targeted attack, so would probably only apply in very specific cases. This is unlikely to happen with Google Fonts, but could apply if you allowed linking to arbitrary web fonts.

Note that it would be possible for any stylesheet to perform similar attacks - for sensitive data, it's generally worth keeping anything that can modify the behaviour or appearance of the application hosted locally, unless you have specific requirements making this impossible.

For sensitive data, I'd advise hosting the fonts (and any other stylesheets and scripts) yourself, if possible, just for peace of mind.


Guidance for "image based" password reset challenge

For any password management scheme building a balance between usability and security can be a difficult task. It might be possible that a particular graphical password technique has a higher usability but less security and vice versa. For example increasing the size of image library would provide a larger password space, but may lead to longer login time.

Images based password schemes offers new challenges as compared to test based password schemes. i.e. Dictionary based attack where majority of users may like to choose from specific set of images. In order to establish basic guidelines we need to conduct a good case study to understand user behavior and identify anomalous behaviors.


What is the use of TPM-based Bitlocker if the drive gets decrypted automatically?

As with any security measure, this reduces the risk, it doesn't eliminate it.

With no TPM, an attacker with physical access can just grab the disk, walk away and read the data at their leisure. If the disk is encrypted with a key in a TPM, the attacker needs to walk away with the whole computer (or at least pull out the RAM and store it safely, to try a RAM remanence attack which isn't fully reliable).

This makes no difference if the attacker has uncontrolled physical access, but it makes a difference if the attacker has limited access, e.g. they're walking around in an office environment or in a coffeeshop and are observed. In such circumstances, it can be very easy to grab a removable drive, it takes less than a minute with a screwdriver to extract a hard disk, whereas extracting RAM tends to require a bit more time and walking away with the whole PC is less discreet.

If the attacker has full physical access, you've lost anyway, though a tamper-resistant TPM plus a PIN to unlock the key can make things hard for the attacker if the machine is powered down before they reach it. Basically, whoever has physical access to the computer owns the computer — but that's only true for unfettered physical access, not in more restricted scenarios. In some scenarios, partial protection is useful.

Use of a TPM-based key should be combined with secure boot, refusing to unlock the drive if not booting the pristine operating system from that drive, so that someone walking past can't just reboot onto their USB stick. It should also be combined with memory wiping at boot time (at least if the last power cycle was not ended cleanly) to prevent cold boot attacks.


Is there any reason I shouldn't make a GPG-encrypted file publicly-accessible?

There is always a risk that any given cipher will be broken at some point and data like this will become truly public. So yes there are some risks but it doesn't mean you aren't making a reasonable security trade-off.

A few things you may want to consider:

What's your worse case scenario with the data going public and are there implications to this data going public that you might not be aware of ?

Are there any time-based factors to this data, such as the data is only useful for a year, a week, etc ?

Are there any regulatory, legal, or ethical implications of this data going public ?

Can you add additional security controls such that it's not just one control protecting the data ?

Do the people you want to share this data with need ALL of the data or could they satisfy their needs with a smaller subset of data ?

Is data masking (replacing sensitive data with known fake data ) an option here which would provide additional security ?

Where will it be decrypted and where will the decryption keys be stored ?

Is the passphrase to decrypt it easy to brute force ?

etc... Millions of other questions go here.

Nothing is 100% secure, everything is a trade-off so you need to look at the decision from a few different angles first.

Generally my advice when I see a single security control is to tell you that you need additional levels of security controls rather than just one. So I would have to advise you to consider additional controls but again even then I don't know what you are protecting and if it's just a collection of Internet cat photos then hey maybe just using GPG is good enough... (no offense to GPG of course, that's a great tool but cat photos are everywhere)


A possible way to allow a privileged user to see what would see a normal user is to implement the ability to (temporarily) drop priviledges in the security layer of an application.

Another way is to let the admin work by default at a regular security level and specifically require a privileged level for administrative tasks. The choice between those way depends on whether the admin mainly process administrative or normal level tasks.

The nice point with both those ways is that an admin will only sees its own data whatever the level, which could matter for sensitive application (medical data for example).

If data sensitivity is not too high, another (maybe more common) way is to allow an admin to impersonate another user. Here the nice point is that the admin will really see the same screen (including same data) as the user, which can help for user assistance.

But whatever the way, it must be explicitely implemented at the application level, specifically in the security layer.


CVE-2020-0601 (CRYPT32.DLL exploit) standalone patch?

Yes, there are specific patches that can be downloaded for each Windows version that is affected by the CVE.

I've provided a more detailed answer on this related question, about how to find and download the correct patch for your Windows release version.


Weird popup on Android 'GNUroot Debian' - what could cause it?

I am the creator of GNURoot Debian.  GNURoot Debian does use VNC for providing a graphical desktop if desired.  If you click the Xterm icon (maybe on accident in this case), GNURoot Debian starts a VNC Server and then starts and VNC client to connect to it.  This is the error you get if for some reason the server is not running when the client goes to connect to it.
Corbin


Is it safe to keep image of cleared check?

The chief risk in this is that the check has routing and account numbers on the image, so if someone were to intercept the download, they would have that information. Something like a MITM or hijacking your site to do XSS to download something besides the check image could be potentially harmful, but that's true of every site and not really specific to your question.

That being said, this risk of someone intercepting the download is relatively low and mitigated by using proper site encryption and secure downloading. SSL, HTTPS, proper certificates, that sort of thing.

The other, much smaller risk is if the end-users computer is compromised and the image is stolen from there - but this is well outside your liability and falls on the end-user to protect their data.


Bitlocker, does additional authentication at startup with TPM device provide any extra security?

Operating system authentication never provides the same level of security than a power-on password. If the TPM gives the encryption key at startup without extra authentication, it's vulnerable against

cold boot attacks

  Problem is that that means that the machine can always be booted up to
  a state where it has encryption keys in memory where they can be
  stolen using a cold boot attack. - -

  None of these mitigations help if you have removable RAM. Then you can
  do the original cold boot attack from 2008.

Direct Memory Access (DMA) attacks (Firewire, Thunderbolt, PCI, PCCARD...)

  An attacker may be able to search for
  BitLocker encryption keys in system memory by spoofing the SBP-2
  hardware ID by using an attacking device that is plugged into a 1394
  port. Alternatively, an active Thunderbolt port also provides access
  to system memory - -

and sniffing Low Pin Count (LPC) bus.

  As the decryption happens automatically, if we can sniff the VMK as
  its being returned by the TPM then we can enter that information into
  any number of BitLocker libraries and decrypt the drive. - -

  TPM2.0 devices support command and response parameter encryption,
  which would prevent the sniffing attacks. Windows doesn’t configure
  this though, so the same attack a TPM1.2 device works against TPM2.0
  devices.

Therefore, Microsoft recommends using TPM+PIN and disabling standby mode i.e. always shutdown or hibernate.


Vulnerability concerning allowed anonymous ciphers found on PKI

Since your question is very vague, I can but guess.

Anonymous cipher means, that the key exchange happens without any authentication taking please, meaning the no (server) certificate is used in the process. But without any authentication, the DH key exchange can easily be attacked by a MitM.

To mitigate this, you have to reconfigure your server software, whatever it may be. Look for the configuration setting where you can enter the allowed cipher suites. if you just want to get rid of the anonymous cipers, you must only disallow the DH_ANON mechanism. Preferably it would be, to put in a whitelist of acceptable cipher suites.

A good guide for the specific settings of popular server software plus a list of acceptable cipher suites is provided by the friendly people of bettercrypto


Does “Restore Factory Defaults” Wipe Out My Data Completely?

First of all, most computer repair places are not fully equiped forensics labs; so, they will probably only be able to see what you've saved since your last reset.

Now, if your computer repair guy is actually a data forensics expert moonlighting as a repair guy, it's a different story.  When you delete data from a computer, all the data stays there but the blocks get marked as deleted; so, a factory reset will generally hide your data without destroying it.  Then as you write new data over the old data, the blocks often only fill up partially leaving fragments of data in what is called the slack space.  There are many tools that can be used to scan slack space for deleted files, but the older a file is and the more often you write to or defrag your disk, the more likely you are to see that data overwritten.  Some tools are designed to make assumptions about previous states of bits based on residual charges meaning that the past few over-rights can be sort-of read, but not with 100% accuracy.

So to answer your question, there may be data left over from one or many of your previous resets for a really smart and unethical person to find, but the older the data is, the less like it is to be recoverable.  That said, having worked with enough IT people in the past, most professional repair places will drill or shatter your drives as a professional courtesy before disposing of it because they expect their clients not to know to do this.  Or, if they choose to refurbish a drive, they will do a multi-pass rewrite to protect your privacy, and their reputation.

As a final disclaimer: technically data can still be pulled from a shattered drive with very expensive forensics equipment, but unless you think you are high up on government watch list, that is not a very realistic concern.  But, if you think tin-foil hats are a reasonable security precaution, and you really want to make sure your data is unrecoverable, the only way to truly do that is to melt your hard drive... but that is supper bad for the environment and your health.


It doubtful that your signing protocol can convey that metadata. As far as is documented, the public key of a keypair generated in the Android keystore contains no telltale patterns that would identify it as such, nor would such a feature necessarily be desirable from a security standpoint. Finally, such metadata would itself need to authenticated to be relied upon, which creates a very complicated trust structure that would be hard to maintain. – James K Polk Nov 5 at 20:09


Is it safe to use third party OIDC ID Token as our APIs bearer token?

It is not advised to use ID Token for providing access because that is not its purpose. When an application does authentication, it needs to to first verify the identity of a user and only then allow access. Verification of identity is done by validating the ID Token while access is allowed by validating the Access Token.

An ID Token proves "who is the user?". Possessing an ID Token does not mean having access.

An Access Token is a bearer token used to allow access from a client application (who has the token), to a resource server (who validates the token, e.g. an API), on behalf of the user (because the user consents to it - e.g. implicitly during login or after that).

Both of these tokens contain an audience (aud) claim that specified the intended audience for the token. The ID Token's intended audience is the client who requested authentication (on behalf of the user). The Access Token's intended audience is the resource server.

If the audience of the Access Token provided to you doesn't include your application, then you shouldn't use it for controlling access to your APIs. In this case, you are correct that you'd need to issue your own Bearer token for the API. However it is not suggest to use the ID Token instead simply because it is not its purpose.


TLS key exchange algorithm = Certificate signing algorithm?

that means that the public RSA key of the certificate is signed using the SHA-1 hash.

The certificate is signed and not the key. The key is part of the certificate but a certificate needs more, i.e. subject, issuer, when it is valid, how the key can be used ...

  Now does that mean that RSA has to be the key exchange, too or is the public key of the certificate used for authentication only?

Since the authentication is done using the certificate and the certificate contains only the RSA key the authentication is done with RSA. The key exchange can be RSA but can also be Diffie-Hellman. The latter one is actually the recommended way. With TLS 1.3 RSA key exchange is no longer possible (i.e. always Diffie-Hellman) but RSA authentication can still be done.

  If I use RSA as key exchange and for my certificate, will I have two separate key pairs?

With RSA key exchange the same key is used as for authentication - i.e. the only key which is contained in the certificate.


How does the quarantine of anti-virus/malware software work?

Many AV function the same way but may have different specific mechanisms of action. In general they work like this:

  When MBAM removes an item such as a file or a Registry entry and
  "quarantines" the item, it is removed from its original location and
  stored in a protected container. Both the removed item and it location
  are stored in the container in a way that the file is rendered inert
  and the location of where it was removed from is also restored. Thus
  if it is deemed to be a False Positive declaration, the item removed
  (file or Registry entry) can be restored to its original and working
  state. If however the item(s) are deemed to be justly removed for
  malicious activity, the quarantine can be "dumped" such that can not
  be restored and the container no longer holds any more quarantined
  items or you can choose to be selective on what is dumped from
  quarantine.

SOURCE

There is also another post on the InfoSec SE that has some additional info:

  In most anti-virus programs, the quarantine files are stored in
  internal binary formats. Since there is no physical connection between
  the infector file to your system (your anti-virus program works as the
  storage format is also a plus point), it is not dangerous.


How to use encryption on a site that only uses an IP address, no domain name?

The only obligation is that the content of the certificate's Common Name (CN) field must be equal to the host name part of your URL.

So, if you want to protect a URL such as https://192.0.2.123/path/to/resource, then your browser will expect a certificate with a Common Name set to 192.0.2.123. No problem if it is a an IP address instead of a Fully Qualified Domain Name (FQDN).

Regarding the Certification Authorities, they may add supplementary requirements for such a request (for instance you will most probably need to own the IP address, ie. it must be a public IP address assigned to you on the RIPE registry or the local equivalent and not a local or a loaned one). So if you don't really need this you may prefer to go with a self-signed one.

As a side note, while using CN fields is the traditional and most widely compatible way to do this, it is now deprecating in favor of using Subject Alternate Names (SAN).


Can a website download documents, images, or other information onto my iMac without my consent or awareness?

In certain cases, yes it can, what it is usually called is a "drive by download": JavaScript exploits, Java exploits (or even you approving the download), and other exploits can indeed infect your computer, if you believe a website is risky you can download the NoScript extension or disable active plugins like Java or JavaScript entirely.

But please know that attacks where a malicious website can download malware onto your computer without your input [downloading a file. approving a prompt, etc], are very rare and will require a zero day exploit which is very expensive.
This is why you are often asked to keep your software up to date, because any exploit found in a certain version can only be fixed in a later version, it isn't going anywhere.


BitLocker with Windows DPAPI Encryption Key Management

DPAPI functions basically two ways, either the info you're protecting is encrypted at a machine level, or a user level.

If you're running as a service, you need to use machine level. If your running under a user, you can use the user level. The difference is that for the user level, the user's password basically provides the encryption for the data you pass to the API. At the machine level it has something to do with the hardware or Windows installation (I'm not sure).

If someone had physical access to the computer, they would not be able to decrypt your BitLocker password without knowing your Windows password (or being logged in as you already). With Machine-Level encryption, it's a bit weaker. Anyone with physical access can get the key. But it does protect against scenarios where the attacker is in a remote location.

Here is your link for using DPAPI with .NET:

http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.protect.aspx

And here is a link for the BitLocker Win32 API:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa376483.aspx

You'll need to do some work on how to use the BitLocker API, because you have to call unmanaged Win32 functions from the managed .NET Framework.


Generating an unguessable token for confirmation e-mails

You want unguessable randomness. Then, use unguessable randomness. Use openssl_random_pseudo_bytes() which will plug into the local cryptographically strong PRNG. Don't use rand() or mt_rand(), since these are predictable (mt_rand() is statistically good but it does not hold against sentient attackers). Don't compromise, use a good PRNG. Don't try to make something yourself by throwing in hash function and the like; only sorrow lies at the end of this path.

Generate 16 bytes, then encode them into a string if you need a string. bin2hex() encodes in hexadecimal; 16 bytes become 32 characters. base64_encode() encodes in Base64; 16 bytes become 24 characters (the last two of which being '=' signs).

16 bytes is 128 bits, that's the "safe value" making collisions so utterly improbable that you don't need to worry about them. Don't go below that unless you have a good reason (and, even then, don't go below 16 anyway).


Yes, your ISP has records of your attempt to visit the original page.  That request left your browser, went through the ISP and to Facebook, which sent back a response of a 503 error, which your ISP also has records of.


Are honeypots successful in preventing attacks?

By the definition of a honey pot, no, they are not a prevention tool.  Honeypots are a tool for behavioral analysis (by seeing what kind of data they are after), slowing an attacker down (by giving them large amounts of noise to manipulate), or fingerprinting an attacker (you have a copy of all the files in the honeypot, and you can compare their downloads to yours).

A honeypot is only available to the attacker after they have compromised your network.  If it isn't the attackers first stop, they may not get there during their attack.

Does anyone employ honeypots as practice?  Yes, I personally know of several companies that handle medical documents that do.  Some military nets use them as well.

Look up honeynet.

Also:

honeypot list


I assume that it is a MySQL database.
1749 (is greater that 0) and nQtm (valid alias - "variable name" for derived table) were chosen randomly by sqlmap. The problem with sleep(N) is that SQL database evaluates it to 0 and hence post=1 AND 0 will be evaluated to zero (FALSE : 1 AND 0 = 0) too. Value 1749 gets interpreted by SQL database as TRUE (similar things (if (42) { ... }) happen in PHP or in python or in C and probably elsewhere but I'm not using that style of coding because it is hard to read and might lead to unintentional bugs).

No delay took place.
http://vulnerable.com/wp-admin/admin.php?action=dt_duplicate_post_as_draft&post=1
AND SELECT(SLEEP(N))

I created just a random query and it still delayed for 3 seconds. So i cannot really explain why it didn't delay in your case (maybe it is not MySQL database (maybe it is Sqlite) or maybe some internal database optimizer skipped that part with sleep(N) because it was immediately evaluated to zero, because there are no if-branches. I ran once in a similar problem with SLEEP(N))
select t.a from (select 1 as a, 2 as b, 3 as c) as t where t.b = 2 and 1=(select(sleep(3)))

Details:
SELECT(SLEEP(1)) returns 0
(SELECT 1749 FROM (SELECT(SLEEP(1))) nQtm) where nQtm is an alias (you can call it a variable if you wish) for derived table (SELECT(SLEEP(1))). If you try to execute (SELECT nQtm.* FROM (SELECT(SLEEP(1))) as nQtm) the result will be just 0 (one row with result 0).
This is same as writing select t.* from (select 0) as t which will result in 0 (you select all columns and all rows here, but since we have only one row and one column the result is 0).
So (SELECT 1749 FROM (SELECT(SLEEP(N))) nQtm) will always result in 1749 - it doesn't matter what you put into SLEEP(N) - it will delay N seconds, but result will be the same (select 42 from (select 0) will always select 42 so it is in some sense independent from derived table (select 0)).

Imagine the original SQL query is:
"UPDATE posts
SET     data='hello world'
WHERE   user_id=42
        AND post=".$_POST["post"];

Now if you make an injection it will result in:
UPDATE   posts
SET      data='hello world'
WHERE    user_id=42
         AND post=1 AND (SELECT 1749 FROM (SELECT(SLEEP(N)))nQtm)

where ... AND post=1 AND (SELECT 1749 FROM (SELECT(SLEEP(N)))nQtm) which is the same as  ... AND post=1 AND 1749 which probably will be evaluated to 1 (which is TRUE) if stored entry for post is also 1 (1=1 AND 1749 same as 1 AND 1749 same as 1). So it will sleep N seconds and then make an update to the DB.
You might exploit it with if...then...else statement. There are 2 of them in MySQL: (if (isMyDogBrown?, true, false)) and (case (isMyDogBrown?) then (true) else (false) end). So now you can construct your query and if something evaluates to TRUE it will sleep for N seconds: (SELECT IF ( substr(@@version, 0, 1)='1'), sleep(5), 0).

Note: You can optimize your query by avoiding time based exploitation (very slow). You can use binary search based exploitation technique e.g. by using the fact the errors in MySQL regular expressions are treated as MySQL errors (so "MySQL/server error" you will evaluate to TRUE and "regular page" to FALSE; ... and it might spam the mysql.log with error messages on that server):
(select (1) rlike (if (".$cmd.", true, 0x28)))

(0x28 = () (https://www.systutorials.com/4670/ascii-table-and-ascii-code/)
Additional notes:

Here is a great source of different exploitation methods which was many years ago my source for learning SQL injection: https://websec.wordpress.com/category/sqli/
If you need to exploit heavy query (time based): https://github.com/sqlmapproject/sqlmap/issues/2909 - you will need to write your own wrapper on localhost (localhost/wrapper.php?id=INJECT_HERE) which will make exploitation easier for sqlmap. sqlmap has sometimes hard time to detect vulnerability.
SLEEP(N) will not always work everywhere (in cases where your SQL query MUST be somewhat broken and not return results which might be evaluated by some filters in the main PHP/whatever script (like login attempts counter etc.)). Sometimes you'll need heavy query based exploitation: https://stackoverflow.com/questions/45666126/strange-behaviour-of-mysql-sleep-function


Shouldn't we all be protected by NATing?

My network admin is convinced that NATing via proxy is enough for protection... used basically to protect from outside attackers, malwares from internet, dns spoofs, and any network based attacks.

NAT helps to restrict access to systems inside an internal network from outside the network in that it only allows data from outside if a matching connection was initiated from inside.

But that's not what today's attacks are usually are. Today the typical attacks against users inside a network use malware attached to mails or delivered when visiting web sites (i.e. malvertisement, hacked web sites, fake antivirus or plugins...). In all these cases the internal user requests the data which means that no NAT will stop it.

And once the malware gets executed the malware connects to its outside masters from to receive its commands and malicious payloads. Since these connections are initiated from the inside NAT will not block anything either.


Different SSL/TLS certificates for subdomains

1) There are no security problems. You only have more private keys, which are secure as long as they are not leaked.

2) With HSTS will be no problem, as long as every subdomain has its own certificate, which is trusted, is not revoked and there is not name mismatch.


How does an android device/os prevent me from getting root?

As already indicated by @Cube in the comment, some (not all) Android phones allow to unlock the bootloader to flash custom kernels and firmware to your device. However, there is only a limited number of models that support it since it is meant for researchers and developers. Also, during the unlocking process you lose all your data, so you cannot use this to silently flash a malicious system or kernel to someone's device without him/her noticing it.
But in general, the bootloader is locked, so this is the one line of defense against getting root: disallowing to flash custom software. As an experimental feature, Android recently also introduced dm-verity to make persistent rootkits even harder.

The other way is to use privilege escalation attacks, meaning you actively exploit a vulnerability in Android that allows you to get root privileges. For example, some services need to run as root, so if you can run code in their context you execute your code with root privileges. However, let's get back to your question about the defenses. First, app's processes are isolated from other processes and the middleware by the kernel. More concretely, Android (ab)uses Linux' user seperation by assigning each app a unique userID. So the kernel isolates them the same way as users are isolated on classical Linux systems. So classical viruses where other programs/apps are infected is simply not possible on Android if there is no critical vulnerability at hand. Also, the middleware contains a lot of access control points where the caller is checked and verified. In addition,
beginning with Android 4 Google started to integrate SELinux into Android as the so called Security Extensions for Android, or SE for Android.
Here, more fine-grained mandatory access control is added to further lower the chance of a successful attack.
When it comes to preventing special kinds of attacks, Android also added support for ASLR in the 4.x versions and extended it ever since then. For example, on newer Android 5 versions binaries are only loaded if they are compiled as position-independent executables.

So this is a subset of all the defenses that Android provides against attacks in general or root exploits in particular. This list is not complete but it gives you an idea what attackers need to overcome and how much the Android devs care about security (which I personally appreciate a lot).


Regarding SSL: SSL Termination may happen before the IDS looks at the traffic. Just because a webserver is capable of handling SSL/TLS doesn't mean that it has to be done at the webserver. There might be a machine at your network border which encrypts and decrypts SSL traffic.

Apart from that, an IDS isn't limited to individual network streams. It might record all traffic and build statistics about what is considered normal. Then if traffic flows suddenly change, for example if the distribution of source adresses changes significantly, or traffic volume massively increases, or there is suddenly traffic between machines that never communicated before, or any other pattern you can think of changes, it might alert humans. This can all be done without looking at the traffic payloads; looking at the TCP/IP header and the traffic volume and timing is enough for this kind of analysis.


What does the below SQL injection indicate?

This is an empty SQL comment, and is treated the same as a space.

This trick can be used to get around filters that strip out spaces. It may also be introduced to bypass a WAF or IDS.


Overwriting hard drive to securely delete a file?

If you use sdelete from Microsoft (http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx)  you don't have to install anything. It has an option to fill the unused disk space with zeroes too. If you already deleted the files this is what I'd just to make sure that nothing remains of the original file.


What are the risks of setting a cookie to have a more global scope?

You're talking about two different scoping properties.  examp.example.com is a domain scope, and / is a path scope.

/ means that the cookie is valid for any URL path within the relevant domain scope.  examp.example.com is that relevant domain scope.

To answer the question in your comment, yes, you want to specifically scope your cookies to your sub-domain to prevent them from being sent along with requests to other sub-domains, where they could be read by those who have no business reading them.   So you do not want to scope cookies that are specifically for examp.example.com to .example.com, or rely on any cookies that are scoped to example.com.


Browser-based proxies only work in the context of your browser. All other non-proxied actions (such as Skype, et al) will be performed in the context of your ISP.

Here's a better explanation:

You use a browser-based proxy for web-surfing. While surfing, if the VPN actually works correctly, you will appear as the proxied address. For example, overflow.my.buffalos-proxy.co.uk
You don't use a proxy to connect to anything else. You will appear as what your ISP designates you as. For example, c-13-333-33-37.hsd1.ca.comcast.net (fake address) when playing games / Skyping / et al.

  I understand that they re-rout your internet traffic through different secure servers making it difficult to track and intercept but what is actually happening?

Here's a dumbed-down version of what's happening:

You connect to your VPN before sending a request through an encrypted connection.
Your VPN receives the encrypted content, and decrypts it. If you're using HTTPS, it will be preserved. Remember, you're just encrypting the data to and fro. A man-in-the-middle attack is possible.
Your VPN connects to the website, and sends the request you asked for.
The website returns the data to the VPN.
The VPN encrypts the traffic, and sends it back to you.

Does hiding behind proxies protect you?

Using a browser-based VPN plugin can betray you if you have Flash, Java, or even other plugins installed. Anything that can get read/write access to your file system will betray your presence.

There has also been a recently-discovered exploit that affected users of private internet access, a VPN provider.

It's also not that difficult to track you online, even if you're behind a bunch of proxies. Why?

Browser-fingerprinting

This essentially allows anyone with access to a browser-fingerprint database to track your surfing habits, if you have Javascript, Java, and/or Flash enabled, or aren't using a plugin to randomize your values on page load. Even with a plugin that randomizes these values, Flash and Java will betray you, and Javascript can do so as well, but not to the extent of what Java and Flash can do.

Surfing with Javascript Enabled

Javascript is notoriously exploited, and there are always new vulnerabilities popping up. Anything that can execute remote code on your system is dangerous. D

Surfing with Flash Enabled
Become a victim of Java exploits, or even legitimate Java programs.

There are multiple tricks to reveal your network interface / computer hardware information. Unique serial numbers on devices are a thing, and this is one of the ways Microsoft attempted to thwart piracy, only to affect legitimate users the most.

Signing into services/accounts that you normally use, while surfing anonymously.

For example, keeping Steam, Skype, or something else running, or even having Windows check for updates! These leave a huge bread-trail.

Using browser plugins with read/write access.
Analyzing connection logs for recent activity.

User A connected to Proxy A at X time.
Proxy A connected to Proxy B close to X time at Y time.
Proxy B connected to Proxy C close to Y time at Z time.

Your VPN disconnected you at an inopportune time, and you reestablished connection to all services under your real IP.

  Also continuing with the browser plug-in theme, do these VPNs re-route all network traffic or just data that is directed through your browser, specifically will they also redirect traffic from desktop games etc that are played online?

Browser plugins in general will only re-route traffic to and from the browser's requests. That's it. If you're playing a browser-based game, then sure, I don't see why not.

Desktop games will not be redirected unless the browser plugin does some weird tomfoolery that manages to install an application on your desktop which does this.


Can a random person find me if my location services are turned off?

Since nobody has bothered to write an actual answer: the phone company can certainly locate you. The precision isn't great, because it's based on how strongly your phone's signal is picked up by nearby cell towers (which will vary depending on things like objects in the way and is going to be a bit fuzzy anyhow because the signal strength measurement isn't designed for precise range measurement). If there are a lot of towers nearby, then you can probably get precision down to something like "that house" or possibly even "that wing of the house", which is probably good enough (it would generally work for police dispatch, certainly). If there's only one tower actually in range - which is uncommon in a city but happens out in the country sometimes - then all they can get is that you're somewhere in the tower's coverage area, and an approximate distance (presenting a rough ring around the tower).

It's worth noting that even when not expressly trying to triangulate you, the phone company will always know approximately where you are by which tower your phone actively communicates with. The system is designed to automatically and near-instantly hand off communication to another tower when you get closer to it, and this can sometimes be used to track people with loose precision. A common example is a phone in a car going down the highway; you can track about where the car is, and how fast it's going, by watching the phone switch from tower to tower as it moves. If there's only one highway along that route (and it's going too fast for any side streets that may parallel the highway), you can be pretty sure the phone is in a car on that highway, and also know roughly where it is (enough to set up a roadblock, not enough to identify the specific vehicle without further work).

Note that while turning off the cellular radio (Airplane Mode) will make it impossible to track you this way, taking out the SIM card will not. The phone presents two identifiers in normal use: the IMSI (subscriber information, which comes from the SIM card and ties the phone to your phone number, account, etc.) and IMEI (equipment information, which is stored in the phone's radios and identifies the phone hardware; it's possible to use it to track or block stolen phones, and enables emergency calls even when there's no SIM present).

In addition to the cell phone company (which will generally cooperate with law enforcement, certainly if they have a warrant), people (including law enforcement) with fake or portable cell phone "towers" could track you if you're close enough to the device for it to pick up your phone's signal. (The one used by law enforcement is known as a "Stingray", but you can build one by hacking the "femtocells" that some carriers will provide to improve signal in your house or whatever.) It's more common to use such things for intercepting phone conversations and data transmissions than for tracking, but at the very least the fact that one of them sees your phone can localize you to a specific area.


How secure is pgAdmin to save database password?

In pgAdmin 4.x the password file location can be specified in GUI whereas pgAdmin III has a fixed path. Both documentations refers to the PostgreSQL libpq (C Library) documentation for The Password File:

  The file .pgpass in a user's home directory can contain passwords to
  be used if the connection requires a password (and no password has
  been specified otherwise). On Microsoft Windows the file is named
  %APPDATA%\postgresql\pgpass.conf. Alternatively, a
  password file can be specified using the connection parameter passfile
  or the environment variable PGPASSFILE.

  This file should contain lines of the following format:

hostname:port:database:username:password

TL;DR: It's unencrypted in a file.


How to secure my network and system setup?

A) I'd use ufw reverse technique by denying all ports as default and allow the ones you do use.

B)
Well, that you can always do...taking care of your system's security. I think you've got yourself a decent setup, perhaps installing and configuring Snort on the switch would be a great idea. I'd also recommend Tripwire but due to the Ubuntu's regular updates, you would have plenty of false positives.

The other thing you can always do is to test your setup with scanning and penetration tools, most of which you can get by installing Kali linux.


What is stronger - WPA2 Enterprise with 2048 bit key, or Personal with 63 character passphrase?

Security from exhaustive search
Ignoring the benefits and drawbacks of each protocol and focusing exclusively on the difficulty of a brute force attack, the answer is that they are both identical. The reason for this is that the only difference between the two is how the key is derived. When using WPA2 Enterprise, a random 128-bit key is generated and exchanged using public key cryptography. For WPA2 Personal using a passphrase of any length, a 128-bit key is derived from the passphrase itself using a key-strengthening algorithm called PBKDF2.* Regardless of how it is generated, the session key will have a keyspace of up to 2128. For a 63-character random passphrase, the entire 2128 keyspace of the session key is used.
Security from cryptanalysis
If on the other hand you are referring to any type of cryptoanalytic attack, the answer is that the WPA2 Enterprise option using RSA 2048 provides less security. RSA 2048 is approximately equivalent to a 112-bit key. The reason for this is that attacking RSA is not done using brute force, but by attempting to factor a very large composite number. RSA uses the so-called integer factorization problem, a problem in mathematics which states that, while it is easy to multiply two huge prime numbers, factoring the resulting composite number back into the original two prime numbers is very, very hard.†
The most effective algorithm for factoring large numbers is called GNFS, which is significantly faster than an exhaustive search, but is still far too computationally-intensive to perform on realistic semiprimes. When you are using a 63-character passphrase on the other hand, it is directly converted into a 128-bit key by PBKDF2 using 4096 iterations of HMAC-SHA1. If the 63-character passphrase is chosen randomly from a US keyboard with 95 printable keys, it gives a keyspace of 9563, which is far greater than 2128 (it has the equivalent security of log2(9563) ≈ 413.9 bits). Because the session key is only 128 bits, the entire keyspace of the 63 keys is not used, only that of the 128-bit session key.
Security in practice
In practice, WPA2 Enterprise using public key cryptography is more secure. This is not because it is more difficult to attack with cryptanalysis, but because it provides other security benefits such as forward secrecy, which ensures that an attacker who compromises one session will not be able to then retroactively decrypt previously recorded sessions, because each key is generated randomly for each session. WPA2 Personal on the other hand uses the passphrase to derive the key, and as long as the passphrase remains the same, any data encrypted under that passphrase can be decrypted as soon as you learn what it is. Because WPA2 Enterprise allows the key to be generated entirely randomly, there is no risk of using a poor passphrase that can be broken.
It is often not easy to maintain a fully random 63-character password among multiple devices. If you are using the complete 95 character set from a US keyboard, you only need 20 random characters to fully utilize the entire keyspace of the cipher, as 9520 is just barely above 2128. Adding more characters would only be useful if you expect them not to be entirely random.
You should be aware that WPA3 has been announced. It is a new protocol which vastly improves wireless security. It provides individualized encryption even on open networks, allowing people to securely use hotel and airport hotspots without worrying about passive eavesdropping, and allowing people to share their key with guests without allowing them to read their traffic. It does this by dissociating the user-supplied key from the encryption. In other words, the key you provide is only used to authenticate yourself to the hotspot. Public key cryptography will automatically generate a per-use random session key. WPA3 comes with other improvements as well, such as a larger 192-bit key. The protocol will be slowly rolled out to new devices during 2018.
Note that I am assuming WPA2 is configured to use CCMP which uses AES128 in CCM mode, rather than the broken TKIP which uses the much weaker RC4 stream cipher.
* It is slightly more complicated than this. The PSK is not directly plugged into the cipher after going through PBKDF2. Instead, a 4-way handshake is done which relies on the secrecy of the PSK. It suffices to say that knowledge of the PSK allows anyone who has captured traffic (including the 4-way handshake) to decrypt the session.
† Integer factorization is an open problem in mathematics. It is possible that a classical algorithm will be discovered that can factor a large semiprime in polynomial time. Additionally, quantum computers running Shor's algorithm will do this in polynomial time. There are no publicly known cryptoanalytic quantum computers in production.


Identifying devices in mobile app using UUID

Here is a list of tips/techniques that you can use:

If users are authenticated and you assign a unique uuid, just allow one TCP/HTTP/HTTPS connection for a given uuid. By doing this, you will limit the number of connections to your service that can use the uuid.
If somebody wants to reuse a uuid or do a "uuid attack" by flooding from requests you can use a basic rate limiting in combination with a IP dropping/blocking rule on a firewall.
On the generation of your uuid use a good crypto library that generates real random numbers, you can also use the last 8 bytes(for example) to do a hash of ip + user credential in the case that your random generator is not good. For example: <8 bytes random>-<8 bytes random>-<8 bytes random>-<first 8 bytes of sha256(ip + user cred)>

Hope it helps


Is PBKDF2-based System.Cryptology.RFC2898DeriveBytes() "better" for Unicode Password hashing than traditional methods?

PasswordDeriveBytes implements the PBKDF1 key-derivation function. A KDF is a function which transform a piece of secret data (here, a "password", i.e. the kind of data which fits in a human brain and can be typed with human fingers) into a sequence of bits adequate for algorithms which need a symmetric key (e.g. symmetric encryption). A KDF is not meant for anything else, in particular password storage.

A hash function can be used as a KDF, provided that the symmetric key you need is no longer than the hash function output size. However, such a KDF would be very crude. One feature which good KDF should provide is to be adequately slow. This is because "passwords" are, by nature, vulnerable to exhaustive search (also known as "dictionary attack": users tend to choose as passwords rather simple words or combinations which can be guessed with only a few millions or billions tries). In a given system, one can usually tolerate a relatively slow KDF: a user trying to authenticate will not see the difference between a 1µs and a 1ms delay for the key-derivation function; but a 1000x slowdown is deadly for the attacker: it converts a one-day breaking effort into a three-years breaking effort.

PBKDF1 includes an "iteration count" which is a parameter meant exactly for that: to make the key derivation adequately slow, in a configurable way. A simple hash function is just too fast for that. Usage as a KDF is precisely where you would prefer PBKDF1 over a hash function. Actually, PBKDF1 is not recommended; PBKDF2, from the same standard, is supposed to be more robust.

Hash functions are much more generic objects than KDF, and have many other usages, which KDF do not fulfill.

What you want to do is unclear: you use the term "signature", which normally means "asymmetric digital signature" as with RSA or ECDSA; there are some people who tend to use the term "signature" to designate a symmetric integrity check, such as a MAC (calling it a "signature" is improper, but widespread). However, this entails some piece of secret at some point, a key, and a hash function is key-less.


PHP would this be risky (using hackable data for includes)

Very risky.

The first could be used to perform operations on the wrong database, possibly bypassing access restrictions (I don't think it could access the MySQL internal database because of the underscore, but I could be wrong).  The second could be manipulated to access any "functions.php" file in the filesystem, and if you also permit file uploads, this could allow unrestricted code injection.  I don't know enough about PHP to know the full range of code injection permitted by the third example, but it looks highly dangerous (eg. passing a function of "system").

Edit:
The correct way to deal with user input is to develop a whitelist that describes "known safe" input.  In the case of $function, that means a list of acceptable function names; for mysql_select_db, a list of values for $table that the user is permitted to access.  If you see an invalid value for user input, reject the entire transaction with a suitably vague error message.  Anything else is just inviting problems from attackers who are cleverer than you.


Where do products like BlueCoat and ForcePoint get there URL categorizations from?

As a former, long-time bluecoat customer, I can give you some insight.

Two main sources:

Threat intelligence sources - many ingest the same sets of data regarding what's a malicious source and what is not. As a result, you're going to see a lot of overlap between products.
Mass quantities of people - Bluecoat specifically has people whose sole job it is to review new sites and suggest categorizations, or to review suggested changes to those categorizations.

What your customers are doing - blocking "new" and "unclassified" sites is absolutely best practice. Given the rise of fast flux DNS, and domain generation algorithms, the number of legitimate new domains is an order of magnitude less than malicious or spammy ones.

I'd suggest simply setting your customers expectations and understanding the support models for these major vendors to ensure that your new sites can be opened up as soon as possible.


What are the security implications of systemd compared to systemv init?

(mostly) people don't inject vulnerabilities deliberately, they occur by accident. As the volume of code increases, the number of defects increases. But its not just size - the number of bugs increases with the complexity of the code and it increases faster than linearly. So more code is bad news for security.

The attack surface of systemd is massively larger than initd - the default configuration has multiple interfaces.

A big annoyance for me is the design philosophy; the intention is that systemd provides a more unified way for distributors to integrate services. But this means removing control over the system from syste admins (over and above the impact of replacing a complex but well understood eco-system). It deliberately makes it hard or impossible to achieve thing which could be done with initd (note that there are many options for service managers running under initd - djb daemontools, upstart, initng, rund, procd, openrc.... Most of which solve the paralellization / dependency problems that limit the sysv rc init system).

A lot of the logic of the start up of a unix system is implemented in shell scripts. This makes it much easier to not only reverse engineer the operation but also to instrument it and extend the capabilities. Systemd moves more logic into binaries and relies more on a complex and poorly documented configuration.

The combination of deliberately reducing the level of control by the system administrator and failing to support the system administrator in their task makes it more difficult for them to do their job - which encompasses assuring the security of the system.

A further consequence of all this complexity in PID 1 means that you should have to reboot your system a lot more frequently. In addition to the impact on availability this also means moving your system through a series of interim states - which can temporarily expose vulnerabilities which are difficult to detect on a homeostatic system. Using daemon-reexec to work around this brings a new set of problems.

The benevolent-dictator-for-life model seems to work well for the linux kernel, but that is not how the rest of the open source industry operates. Indeed it is perhaps the exception which proves the rule - that open source works because nobody is in charge, not despite nobody being in charge. Systemd assumes control over a lot of the functionality in a linux system, yet it operates as a relatively small community. And as per the pwnie award it appears to be somewhat inward looking: there are not a lot of eyeballs on the code: nobody is listening when concerns are raised about the code.


Found some mysterious folders in each of my drive in windows 10

The names are generated, so you definitely it looks like some kind of infestation.

But it looks like RansomFree, a program that creates fake known types of files and monitors these files, and whenever they change, it detects the originating process and pauses it.

Be aware that other malware may trick you and do something similar.


Best security practices in internet cafe

If you don't own the hardware you have no control.  Anything you could run within that Windows environment could be logged at the keyboard and mouse input level if nothing else.  If you don't trust the computer, don't use it and bring your own device.  It's the only way.


Does password length / complexity make any difference if hashes are leaked?

Say you have a dozen people on a beach. You get each person in turn to pick a grain of sand at random, and without looking at it, write their name on it and throw it back randomly onto the beach.
What are the chances two people write their name on the same grain of sand?
The size of the key-space for human-generated passwords is around 40 bits according to Wikipedia. The key-space for most modern cryptographic hashes is 128 or 256 bits.
This is such an astronomical difference in the sizes of the two sets, the overwhelming majority of possible hash values are not reachable from a typical password. The chances of a collision are like two people picking the same grain of sand on a beach.
To reach a collision, you would typically have to iterate through half of the hash key-space. In doing so you would have to generate a password that is likely to be far longer, and far less like a human-chosen word, that the actual original password would have been much easier to guess.


Using X-actual-recipient to divert email

We can simplify this issue and say that any email administrator (or root account on an MTA) can redirect, bcc,  resubmit, edit or delete any or all email on that given server "covertly".  In other words, without the sender or recipient knowing about it.  This modification can happen on the sender's side, recipient, any MTA in their path, or ISP (PRISM).

If such a modification were to occur then something called the "message envelope" would be right place to make this happen since it doesn't appear in the email headers.  The only risk I could find regarding X-Actual-Recipient is that it may disclose the target email address in an NDR.   If this header did affect mail routing than it would be worrisome, because that email server might as well be considered an open relay.

To correct this issue you should consider any of the technologies and implementations listed here:


Can MitM attack be avoided without using a 3rd party?

There is no need to use a CA, even with HTTPS. You can simply use a self-signed certificate on the server if you provide the client with a copy or similar (i.e. fingerprint) of this certificate in a secure (tamper proof) way before the client connects to the server so that the client can verify that it talks to the expected server. If the client can not verify the server man in the middle attacks are possible.

The concept of CA signed certificates (i.e. public key infrastructure (PKI)) is only created because sharing a self-signed leaf certificates with all parties does not scale. With CA the browser/OS has a list of trust anchors (root certificates) and can derive the trust to a server certificate based on a trust chain from the trusted root to the leaf certificate. Because of this mechanism only the trusted root CA need to be shared but not every possible server certificate.

Apart from a pre-shared certificate or similar public information (like a SSH server fingerprint) MITM resistant connections can also be established by using a shared secret on both sides. That's the typical case in home Wifi protected with WPA.

Limited protection against MITM is achieved with Trust On First Use (TOFU). In this case the identity of the peer is saved from the first connection and applied to the following connections in the hope that the attacker was not present on the first connection, i.e. that the identity received was the true identity of the expected peer. This is done for example if one accepts a self-signed certificate in HTTPS.


How can I put in relation http timestamp with country time zone of the IP?

There is just one field for the date in the header.If it is missing the recipient adds one.Taken from http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18
14.18 Date

The Date general-header field represents the date and time at which the message was originated, having the same semantics as orig-date in RFC 822. The field value is an HTTP-date, as described in section 3.3.1; it MUST be sent in RFC 1123 [8]-date format.

Date = "Date" ":" HTTP-date

An example is

Date: Tue, 15 Nov 1994 08:12:31 GMT

Origin servers MUST include a Date header field in all responses, except in these cases:

If the response status code is 100 (Continue) or 101 (Switching Protocols), the response MAY include a Date header field, at the server's option. 2. If the response status code conveys a server error, e.g. 500 (Internal Server Error) or 503 (Service Unavailable), and it is inconvenient or impossible to generate a valid Date. 3. If the server does not have a clock that can provide a reasonable approximation of the current time, its responses MUST NOT include a Date header field. In this case, the rules in section 14.18.1 MUST be followed.

A received message that does not have a Date header field MUST be assigned one by the recipient if the message will be cached by that recipient or gatewayed via a protocol which requires a Date. An HTTP implementation without a clock MUST NOT cache responses without revalidating them on every use. An HTTP cache, especially a shared cache, SHOULD use a mechanism, such as NTP [28], to synchronize its clock with a reliable external standard.

Clients SHOULD only send a Date header field in messages that include an entity-body, as in the case of the PUT and POST requests, and even then it is optional. A client without a clock MUST NOT send a Date header field in a request.

The HTTP-date sent in a Date header SHOULD NOT represent a date and time subsequent to the generation of the message. It SHOULD represent the best available approximation of the date and time of message generation, unless the implementation has no means of generating a reasonably accurate date and time. In theory, the date ought to represent the moment just before the entity is generated. In practice, the date can be generated at any time during the message origination without affecting its semantic value.


What would be a secure way to handle password prompts in shell?

You assume (as do a lot of people whom should know better) that when you input a password there is some some magic mojo protecting its cleartext in the program. If you can assure the integrity of the program reading the password and it does not deliberately persist or export the cleartext, then it will not be accessible to other programs.

A script is slightly easier to compromise than a binary program assuming that the attacker has root level access to the filesystem - but at that point its already pretty much game-over. There is an argument that if the program is swapped out of memory, then the cleartext will persist on the swap space - but that is almost the same problem as protecting the RAM (you shouldn't be using remote storage for swap anyway).

Update
Sergey's answer appears to address what you do with the password after you have captured the cleartext (although its not very clear). But if you are using a shell builtin to inject the password into the target program it will not appear in the output of 'ps'


What is the possible impact of dirtyc0w a.k.a. "Dirty COW" bug?

It can't be exploited remotely without another vulnerability. You need to be able to execute commands on the system already.

A classic example would be a web shell. Say the server is running a web application which has a vulnerability allowing you to upload a web shell or otherwise execute system commands. These commands will typically be executed as a low-privileged user, sometimes called www-data or similar.

With this exploit you could overwrite the file /etc/passwd to give www-data the UID 0. Now www-data has root privileges.

However, I tried a few things and modifying /etc/passwd didn't work on my system. You can set the UID of a user to 0, but then you'd have to re-login, which isn't really an option if you only have a web shell. The best weaponized exploit I've seen so far overwrites /usr/bin/passwd, the binary which is used to change a user's password and has the SUID bit set, with shellcode that executes /bin/bash. Some limitations of the exploit seem to be: You can only overwrite existing bytes, not add anything to a file. I was also not able write more than exactly 4KB to a file.

As for affecting Android, I searched the Android 4.4 git repo for the function in question (follow_page_pte) and got no hits, so I want to say "no", but don't quote me on that.

Edit: Android is affected - see this proof of concept.


What is encryption key reset and why it is safer than zero-write?

Time spent on an operation does not necessarily relate to effectiveness of said method. Simply copying a file to an external drive is much faster and will yield better results than converting it to base64 and then typing it in.
Why is an Encryption Key Reset secure?
Essentially, it means you are okay with the attacker gaining access to your encrypted data, believing that they will not be able to decrypt it. While this sound strange at first, keep in mind that every sensitive information you have ever transmitted over the internet - ranging from your online banking credentials, over health-related data to pictures of your genitals - has undergone this exact process, and we still consider it secure.
We assume that AES-128 and AES-256 is in fact so secure, that without the secret key being known, it is physically impossible to recover the data That's right - we're not talking about statistics anymore, we're talking about physics. Thermodynamics, to be exact. There isn't enough energy in the universe to recover it. And AES has been around since 1998 and it shows no signs of weakness yet.
So when you do an Encryption Key Reset, what you actually do is just delete or overwrite a very small (128 or 256 bit) piece of data. You can do that countless times, very very quickly. As you yourself said, it only takes 2 seconds. I'm sure that after thousands and thousands of writes to the location of the key, it's not recoverable anymore.
Why is zeroing out a drive insecure?
Essentially, you're going down the hard route here. If your data is encrypted already, then zeroing it out or overwriting it with randomness is essentially redundant. Without the key it becomes unreadable anyways, as mentioned above. Zeroing it out certainly doesn't make it less secure, but it won't make it more secure either (practically speaking). What you actually end up doing by zeroing it out is adding wear to your storage, which is particularly bad with SSDs.
Now where zeroing something out is indeed less secure is if the data is stored in plain text, and you're trying to destroy it by overwriting it. Now, the question whether or not a single-pass of zeroing is enough to destroy the data permanently is being debated. Some say it's perfectly fine, others say that specialists can recover the data. I'm not an expert when it comes to forensics, so I will say "Some people claim that a single-pass of zeroing is not enough to fully erase all data" - which is the only factual statement I can give in regards to that.
In the end, zeroing out the key is probably the better method, for various reasons:

It's a lot faster.
It doesn't wear your storage device out.
It's just as secure.
You should use Full-Disk Encryption anyways.


How does malware avoid AV's when using a simple DLL injection technique?

Malwares decode their payloads in memory and manually map their PE structure. The PE is a very simple format, it's doesn't take long to write a PE loader from scratch.
For an AV to be able to monitor a program memory it would either need to pause it periodically and inspect every page of its working area or hook the memory allocation and protection APIs and fiddle with the permission to intercept every write.
Either way that would slow down the programs so much that nobody would use an AV.
By working on memory malwares avoid the AV signatures check, the AV could intercept a call to CreateRemoteThread (and all the one thousand tricks that exploit other APIs or call directly into the kernel) but at that point only the thread starting address is known, that's not enough for the signature check.
By the way, a malware could simply inject the decoding stage in the target process, and since there are infinitely many encoding, the signature check will always fail.
AVs typically work by intercepting malwares when they are written to disk, launched, and when they communicate over the network. These are all relatively inexpensive hooks.
With heuristics and signature checks, they can block the malwares of yesterday.
But AVs are generally useless at catching unknown and updated malwares, so be more surprised when they block a malware than when they don't.
IoCs and base heuristic like "every script interpreted or file downloaded by an Office document is malicous" are far more effective than playing a cat and mouse game with injection techniques.
Almost all malwares want what your user can already access without the need to inject a privileged process (that is probably protected by its high integrity level) and an AV can't arbitrarily block DLL injections between low privileged processes as, alas, there are legitimate use cases for them.


How can I unlock drive without the password or recovery key of Bitlocker?

Simply put: You can't

Bitlocker uses AES-XTS 128 or AES-XTS 256.
As long as the drive is not mounted and unlocked (whereas you could just disable bitlocker or export the password/recovery key) there is no way of bypassung this.


When does it make sense to deploy an embedded firewall on my IoT device?

I mean doesn’t strong encryption and certificate based authentication ensure complete security to IoT device?

Not at all. (Properly used) TLS only protects the communication against sniffing and modification. Mutual authentication only authenticates the IoT device against the server. None of this protects against bugs in the implementation, improper use of TLS, bugs in the server side which can be used to hijack clients, services which are exposed on the network, backdoors in some firmware you got from a third party, compromising the device with physical access etc.
But, an embedded firewall does not protect against most of these other threats either. If it makes sense to use one in your specific case depends on what the device actually does, what the threats are, what the attack surface of the device is and if a specific firewall implementation reduces the attack surface - none of this is known here.


What happens to a certificate's Basic Constraints when a policy map is used?

Certificate policies and basic constraints are completely orthogonal issues. Policy mappings impact the processing of the "policy tree" but do not change the length of the path, and do not make a CA certificate a non-CA or vice versa.

Are you sure you want to use an explicit path length in the Basic Constraints ? This is rarely done; as such, it is quite possibly mis-implemented by some certificate validation engines. Setting an explicit length is used to give to a sub-CA the power to be a CA (i.e. issue certificates) but to prevent them from delegating that power to a sub-sub-CA. It takes some effort to find a situation where such a restriction makes sense: if a CA considers its sub-CA as a potential attacker, then there is something definitely rotten in the kingdom. Said otherwise, an hostile sub-CA already has tremendous power of nuisance even if it cannot issue a sub-sub-CA.

I would advise, for better interoperability, not to include an explicit length in the Basic Constraints extension. Mark CAs as CAs and non-CAs as non-CAs, and that should be enough.


How can I decrypt my files from "Cryptowall" encryption?

I do not want to be pessimistic but the ransomware author is the only party that knows the needed private decryption key. CryptoLocker uses using a mixture of RSA & AES encryption. There are good security practices to prevent your computer from being infected by it, but once infected there is not something to do really about it for the moment. Do not waste money in buying tools pretending to be able to decrypt the files. But if you have done previous some restore point using System Restore of Windows then you have a big chance to recover your files.


Here's a brief explanation regarding the kind of alerts assigned to each group:
attacks: Events associated with attacker activity (brute force and code injection attempts for example).
adduser: New accounts created in the system.
sshd: Events associated with the Secure Shell daemon (for remote access to terminal in Linux machines)
ids: Alerts from Intrusion Detection Systems.
firewall: Events from firewall software or hardware.
squid: Events from the Squid proxy.
apache: Events from the Apache web server.
syslog: Syslog messages from various sources (this can be software, network devices or other syslog producing sources).


What do you see as the emerging threats for 2011

According to McAfee Labs Threat Predictions for 2011:

Exploiting Social Media: URL-shortening services
Social media sites such as Twitter and Facebook have created the movement toward an “instant” form of communication, a shift that will completely alter the threat landscape in 2011. Of the social media sites that will be most riddled with cybercriminal activity, McAfee Labs expects those with URL-shortening services will be at the forefront. The use of abbreviated URLs on sites like Twitter makes it easy for cybercriminals to mask and direct users to malicious websites. With more than 3,000 shortened URLs per minute being generated, McAfee Labs expects to see a growing number used for spam, scamming and other malicious purposes.

Exploiting Social Media: Geolocation services
Locative services such as foursquare, Gowalla and Facebook Places can easily search, track and plot the whereabouts of friends and strangers. In just a few clicks, cybercriminals can see in real time who is tweeting, where they are located, what they are saying, what their interests are, and what operating systems and applications they are using. This wealth of personal information on individuals enables cybercriminals to craft a targeted attack. McAfee Labs predicts that cybercriminals will increasingly use these tactics across the most popular social networking sites in 2011.

Mobile: Usage is rising in the workplace, and so will attacks
Threats on mobile devices have so far been few and far between, as “jailbreaking” on the iPhone and the arrival of Zeus were the primary mobile threats in 2010. With the widespread adoption of mobile devices in business environments, combined with historically fragile cellular infrastructure and slow strides toward encryption, McAfee Labs predicts that 2011 will bring a rapid escalation of attacks and threats to mobile devices, putting user and corporate data at very high risk.

Apple: No longer flying under the radar
Historically, the Mac OS platform has remained relatively unscathed by malicious attackers, but McAfee Labs warns that Mac-targeted malware will continue to increase in sophistication in 2011. The popularity of iPads and iPhones in business environments, combined with the lack of user understanding of proper security for these devices, will increase the risk for data and identity exposure, and will make Apple botnets and Trojans a common occurrence.

Applications: Privacy leaks—from your TV
New Internet TV platforms were some of the most highly-anticipated devices in 2010. Due to the growing popularity among users and “rush to market” thinking by developers, McAfee Labs expects an increasing number of suspicious and malicious apps for the most widely deployed media platforms, such as Google TV. These apps will target or expose privacy and identity data, and will allow cybercriminals to manipulate a variety of physical devices through compromised or controlled apps, eventually raising the effectiveness of botnets.

Sophistication Mimics Legitimacy: Your next computer virus could be from a friend
Malicious content disguised as personal or legitimate emails and files to trick unsuspecting victims will increase in sophistication in 2011. “Signed” malware that imitates legitimate files will become more prevalent, and “friendly fire,” in which threats appear to come from your friends but in fact are viruses such as Koobface or VBMania, will continue to grow as an attack of choice by cybercriminals. McAfee Labs expects these attacks will go hand in hand with the increased abuse of social networks, which will eventually overtake email as a leading attack vector.

Botnets: The new face of Mergers & Acquisitions
Botnets continue to use a seemingly infinite supply of stolen computing power and bandwidth around the globe. Following a number of successful botnet takedowns, including Mariposa, Bredolab and specific Zeus botnets, botnet controllers must adjust to the increasing pressure cybersecurity professionals are placing on them. McAfee Labs predicts that the recent merger of Zeus with SpyEye will produce more sophisticated bots due to improvements in bypassing security mechanisms and law enforcement monitoring. Additionally, McAfee Labs expects to see a significant botnet activity in the adoption of data-gathering and data-removal functionality, rather than the common use of sending spam.

Hacktivism: Following the WikiLeaks path
Next year marks a time in which politically motivated attacks will proliferate and new sophisticated attacks will appear. More groups will repeat the WikiLeaks example, as hacktivism is conducted by people claiming to be independent of any particular government or movement, and will become more organized and strategic by incorporating social networks in the process. McAfee Labs believes hacktivism will become the new way to demonstrate political positions in 2011 and beyond.

Advanced Persistent Threats: A whole new category
Operation Aurora gave birth to the new category of advanced persistent threat (APT)— a targeted cyberespionage or cybersabotage attack that is carried out under the sponsorship or direction of a nation-state for something other than pure financial/criminal gain or political protest. McAfee Labs warns that companies of all sizes that have any involvement in national security or major global economic activities should expect to come under pervasive and continuous APT attacks that go after email archives, document stores, intellectual property repositories and other databases.

please see the full article here


Can I fool keyloggers by simulating fake key strokes?

Depending on the OS, it may be trivial for the keylogger to distinguish different input sources and filter out your random characters. And even if that's not the case, there are many places aside from the keyboard where a decent trojan will be looking for passwords, like RAM contents and screenshots.

Aside from that, your method will only work if you introduce lots of random characters. Let's assume the keylogger has captured a sequence of N characters corresponding to M characters of the password and N-M random characters added by your method. Assuming M is known, there are C(N,M) possible passwords for the attacker to try. For example, if the keylogger has captured 16 characters and the password is known to be 8 character long, the attacker will discover the right password in

C(16,8) = 12870 attempts

If the password length is not known, the attacker could simply iterate through different possible values. For example if in the example above the password is known to be between 8 and 16 characters, the attacker will have to try out 39203 possible passwords.

Only when you add about 250 random characters to your 8 character password, the difficulty of cracking the keylogger data becomes equal to brute forcing an alphanumeric password. At this point, you should make sure you have a good random characters generator, because these 250 characters could be enough to crack the trivial ones.


What are the risks of publicly hosting OWASP Juice shop

If you're running nothing else on the same Azure instance, and nothing on that instance's filesystem contains anything sensitive, then there's not much of a risk factor.

I reviewed a writeup of all the challenges on the Juice Shop, and several of them involve SQL injections that could allow you to modify content on the site. I think your biggest problem is going to be that an attacker could inject a bunch of malicious content and turn your site into a phishing domain or something. Since it's a forum-style product you may also find that spammers fill up your instance with junk. If you're only running this short term and intend to kill the instance after a day or two then I wouldn't worry about it at all.

One countermeasure you could take is to implement HTTP Basic Auth on the webroot of the instance, so that all requests require authentication. That way you can run a public instance but only give access to those who need it.


How can I ensure privacy when outsourcing authentication to an IdP (Identity Provider)

I do not think that it will be a good idea to hide the identity of Service provider(SP) from the Identity Provider (IdP- a trusted third party).

The IdP is providing authentication as a service to SPs that integrate with it.
This comes under federated identity management which is entirely dependent on establishing trust relationships between different domains.
This enables the end users to authenticate themselves with one domain (IdP) and access services which belong to different domains (Single sign-on)
Since the IdP is providing a service to SP It should have a mechanism to identify the SP from which the authentication request is coming from. and to verify the authenticity of the request. (generally implemented by verifying the digital signature of the SP and some kind of prior agreement between the two parties)

Let us say you (SP) do not want to share your identity information with IdP.

After checking for the user's credentials how will the IdP notify the SP that the user is authenticated or not (callback URL is needed)
If there is no strong method to identify the requesting party, some malicious web application may pretend to be you and communicate with the IdP.This may result in compromise of some important information.
Let us consider an extreme case where you are relying on a third party to communicate with the IdP on your behalf. Even then you need to have some mechanism to verify the authenticity of the authentication request.(again you need to share your public key)


Can an XXE (XML External Entity) attack be carried out from within an SVG file?

XXE vulnerabilities are all to do with the parser. If the parser that processes the SVG file grabs external entities without verification, then it is vulnerable.

For an example, see this vulnerability in an Apache library.


is there a term for encryption where decrypting with the wrong key will still result in an intelligible message?

That reminds me of the concept of encryption that offers Plausible Deniability, aka "Deniable Encryption" which has the following property:

  Deniable encryption makes it impossible to prove the existence of the plaintext message without the proper decryption key. This may be done by allowing an encrypted message to be decrypted to different sensible plaintexts, depending on the key used. This allows the sender to have plausible deniability if compelled to give up his or her encryption key.

The commonly-cited use for this is at airports: have two operating systems steganographically overlapped on the same hard drive. When airport security asks you to boot up your laptop, enter the decryption password for the "innocent" OS. Even if they forensically examine your laptop, nobody would guess that there's a second OS hiding in plain sight.

Thanks to @JamesMishra for pointing out in this post that:

  TrueCrypt had a similar hidden operating system feature where the TrueCrypt bootloader would accept two different passwords, giving access to two different operating systems. The hidden operating system was concealed with a bit of clever steganography.

Second, let's talk about this:

  someday a supercomputer might exist that could iterate through all [2512] possible keys and find a key that decrypts the list

I see where you're coming from, but brunt computing power alone isn't enough. See this answer of mine for math showing that counting from 0 to 2208 would require you to consume the energy equivalent of the sun.

The YouTube channel 3Blue1Brown has an excellent video showing just how mind-bogglingly large the number 2256 is.

How secure is 256 bit security?

In summary:

2^256 = (4 billion) x (4 billion) x (4 billion) x (4 billion) x (4 billion) x (4 billion) x (4 billion) x (4 billion)

Counting from 0 to 2256 would require: a GPU capable of doing 4 billion ops/s x 1 kilo-Google's worth of servers x 4 billion people each having their own personal kilo-Google's worth of servers x 4 billion copies of the planet Earth x 4 billion copies of the Milky Way x 37 time the age of the universe. And we're still missing one more factor of 4 billion. Yeah, 2256 is an unfathomably large number.

Your intuition is not entirely wrong though; over time we do get better at cracking encryption keys, but that has more to do with advances in understanding the mathematics of a specific encryption algorithm that let us narrow in on likely keys, but brunt computer speed alone won't even get us there.


Should I trust URL based on file extension like this: http://example.com/image.jpg

Even images may contain malware, for instance a lot of embedded devices have been jail broken via vulnerabilities in libtiff.

More than that, URL extensions will not always match the real file name. The value may be rewritten by HTTP headers in server response like this one:

  Content-Disposition: filename="myfile.exe"


I am "Shell Shocked" - remote script downloaded and executed - can I ban file downloads as security measure

Removing curl and wget is merely a speed bump for your attackers. You've got a case of remote code execution, which means you're owned no matter what. /bin/cat /etc/passwd is a favourite for shell shockers -- and you can't remove cat!

What you need to do is update your bash package. You mentioned you've wiped the box and started over. That's an excellent first instinct. Now, you need to update and keep your box updated! The easiest way to do this is through your package manager, so do that before you put it online. Then, set up an auto-security update policy. Consult the documentation for your distro to do that.

You are correct in assuming that your attacker will want to come back to an already-compromised box. After you update bash, you'll be immune to shellshock, but there's still a lot of issues that webservers face. Have you looked into NAXSI? This is a Web Application Firewall (WAF) that can shield your nginx installation from common attacks in a rule-based fashion.


Security-related bug bounties are usually more of a PR event than an attempt at outsourcing a security audit. The message they want to communicate is "Our software is secure, and we are so sure about that that we bet $$$$$ that nobody can find a vulnerability".

When a company places a bug bounty, you can assume that they have also read the standard literature about penetration testing and already patched those vulnerabilities you can find with the usual methods. When any newbie could find their bugs, the bug bounty offer would become both expensive and bad for PR.

When you enjoy looking for vulnerabilities, want to improve your skills and want to do good while doing so, you might want to consider to support some smaller open source projects which don't have the resources for a security audit. You won't get paid, but you will collect valuable experience.

A "proof of concept" for a vulnerability is a demonstration which shows that the bug happens. This illustrates that the bug is really there and not just a theoretical approach. It can be a series of instruction like "Click here, click there, enter that, cancle then, click there, clap your hands twice and you have administrator access". Or it can be an exploit: A program which causes the application to misbehave when executed. When proving a bug with an exploit, it is usually expected that you don't just deliver the binary but also the sourcecode and an explanation how it works.


Can I force unique passwords for domain admin accounts?

Forcing unique passwords for both domain admin and Daily account would simply do people so they use like "MyP@ssw0rd1" for their Daily and "MyP@ssw0rd2" for domain admin.

That would do the passwords easly guessable anyways, knowing the Daily password would make it easier for an attacker to deduce the domain password out of this.

The risk you want to protect against, is if malicious software or a malicious user could access the domain admin account, by knowing the password of the Daily account.

To protect against this I would suggest using a 2FA token solution with OTP tokens. Either time synced or event synced. Or even a Yubikey. The good with code-based OTP tokens or yubikey, is that they can be used in legacy password systems by simply replacing the password validation module with one that can validate a code consisting both of a static password and a OTP. 2FA is then only enabled for domain admin, which means the token can be securely locked away in a safe while its not used.

Another solution is to enforce a 2 person access rule. Simple, you have 2 domain administrators. One domain administrator a password half he knows without the other one looking, then the other domain administrator types Another half that he knows, without administrator 1 looking.
Then both persons must come in unison to access the domain administrator account, which both increases traceability but also security since you would need to know both password halves so even if both administrator set their halves to their Daily password, security is not compromised.


What is the best anti virus for kali linux?

Kali is mainly for pentesting. It is not supposed to be used as "desktop distro". As far as I know, there is no antivirus and because of tons of exploits built-in you would destroy the whole distro by just installing it.

I would recommend to used it like:

Install, Update, Setup, Image then
Do a pentest / reimage,
Update, Image if updated
do a pentest reimage.
Update, Image if updated

... Go for Debian for normal use. Kali is based on it. But if you are beginner, I would recommend Ubuntu rather.

Regarding AV, use what @Matt Spaulding recommended


If this is for native apps, you can try the following,

Store an access key in your app bundle. Nobody other than app owner (yourself) can have this.
Change your API so that only requests with the access key set in header will succeed.
Use HTTPS so that nobody can read the encrypted access key.

If you don’t use HTTPS, you can still manually hash the access key with something in the header (only your server and app logic knows how) so that man in the middle can’t pretend to be your app.

If this is for pure web apps,

I would first suggest wrapping the pure web app inside a native app (a.k.a. Hybrid app) so that you can achieve the protection outlined above, by bundling a secret key inside the app. Developing a native app with a single web view inside shouldn't cost too much.

However, if that is not possible, so your app remains a pure web app - here is a potential option,

When server serves the web app, supply an access key.
When the web app makes API call it needs to supply a hashed version of the access key.
How your web app hashes depends on logic that are implemented in minified+obfuscated codes.
Your backend API then validate the hash by applying the same hidden logic to the stored access key to calculate the hash and see if it matches.
You can change the hidden logic and access key as frequent as needed to reduce the chance of someone getting the right hash.

This is of course not bullet-proof but as you know, there is no perfect security and this probably achieves the purpose (and hopefully fits the bill). I would say going hybrid is more cost-effective though.