how to specify pkcs#7 requirements for a third party you are exchanging data with?

It looks like you asked a second similar question shortly after asking this question. However, the bounty is here, so I'll give it a shot!
In your other question, you mention that you're looking for confidentiality and non-repudiation as part of your file exchange scheme. This means that you're looking to send data from Alice to Bob such that Bob can verify that Alice (and only Alice) could have sent the file and Alice can verify that Bob (and only Bob) can read the contents. You're also, as far as I can tell, looking to send this data in a single package, so you only have to send one communication with all of the information required.
PKCS7 is an older format that's been largely wrapped up in the Cryptographic Message Syntax (CMS) format, which includes PKCS7 data, but also has many more features. This format is primarily used for sending encrypted email (S/MIME), but you could theoretically use it for your purposes. There are other formats for sending an encrypted package, e.g. using XML, that are standard in various contexts.
But this is overkill. Don't re-implement the wheel.
There are existing tools (e.g. these) that can do public-key file encryption and signing out of the box so that you don't have to risk implementing your own cryptosystem. If you can use GNU Privacy Guard (GPG) or another tool like it for this purpose, I would recommend doing that. I would be shocked if these tools couldn't output messages in CMS/PKCS-compatible formats.
If you need something more basic, OpenSSL is capable of encrypting and decrypting signed CMS content on the command line and via the library. There are plenty of examples if you search.
There are also a variety of answers here on Stack Exchange on this same topic, e.g. What's the standard way to encrypt a file with a public key in Java?:

One common, standard encryption format is Cryptographic Message Syntax (CMS, evolved from PKCS#7), and e.g. BouncyCastle supports it. It allows for signatures also, and is the basis, e.g., for S/MIME mail message security. It may be overkill, but is widely supported.
Example code is provided by Bouncy Castle. For CMS, see org.bouncycastle.cms.test, probably the Enveloped Data examples.
Another option is the XML Encryption format, standardized by W3C. For Java examples, see e.g. Exploring XML Encryption, Part 1 or do it with XSS4J: Implementing XML Encryption in Java

For non-repudiation purposes, there are established third-party services that provide timestamping services, along the lines of a notary public validating a paper document, if you need that. These are called Trusted Timestamp Authorities. This way, Bob can verify that Alice signed the document no later than the trusted timestamp, since the document was already signed and encrypted when timestamped by the TTA, and Alice cannot claim to have signed the document later. This could (IANAL) also allow a secure trace for court purposes, if, for instance, Alice and Bob are negotiating a contract and Bob needs to sue Alice later.
It's generally a bad idea, security-wise, for a non-expert to re-implement an cryptography standard. You could, and probably will, make a mistake, usually a protocol error, which would blow your system wide open. As Schneier says, it's trivial to create a crypto system that you yourself cannot break. Using a standard system also allows you to send your data to any recipient, who doesn't necessarily need to know your protocols and interfaces.
Cryptosystems like PGP, GPG, and OpenSSL have been around for two decades and have had the proverbial kitchen sink thrown at them. Security experts still depend on them. So use one of those, if possible.
If it's not possible to use existing libraries and systems (and there aren't very many situations where that would be the case - university homework is one of the few I can think of), you'll need to do at least the following:

Alice and Bob will each need a public and private keypair. When Alice sends a file to Bob, she will encrypt it using her private key and Bob's public key. This means that only Alice could have sent the file, and only Bob can decrypt the contents.
You will need a secure way to communicate keys from Alice to Bob, or at least to verify that the key you received is the key Bob sent. Ideally, you'll need to have your keys signed by a certificate authority like Verisign. If you can't, you'll need to use some kind of trusted out-of-band method of verifying your exchanged public keys. Otherwise, all you've got is a key that claims to be Bob's key.
Please please use a standard mechanism to generate your keys (e.g. OpenSSL).
Do not re-use a symmetric key. Ever. Similarly, don't re-use an initialization vector (IV) for your symmetric system. Ever.
If you need trusted timestamping, as mentioned above, using a trusted third-party service is one of the most reliable ways to accomplish this. You would send them your already-encrypted file, and they would return a package including a signed timestamp and hash of your encrypted blob. If you need this and can't use a third-party, you'll need to figure out a way of securely synchronizing timestamps with Bob before sending the document.
You'll need some way to keep your private keys safe. Using a keystore on the local machine means that your 2048-bit RSA keys are exactly as secure as the sum of your local system password and your keystore password. It's better to store keys in a dedicated crypto module, or perhaps a USB drive kept in a safe when not being used.
You can use a standard format like CMS to transmit your certificate data, or you can roll your own. I'd recommend going with standard formats whenever possible, since the recipient can then use standard tools for decryption.
You may want to consider using separate keys for signing the document vs. encrypting the document. In other words, Alice would have two keypairs - one used to encrypt the symmetric key and a second one used to encrypt the hash. Bob would need both corresponding public keys. The advantage is that you can then swap out your encryption keys on a regular basis without necessarily losing your non-repudiation. The disadvantage is that you'd have to securely communicate each new public key to Bob.

Please let me know if you need any further clarification. I cannot stress strongly enough that you should use an existing, tested, and accepted cryptography system if it's available for your purposes.


DNSSEC: Why are RRSIGs returned in the "Answer" not "Additional" section?

It seems that the idea is to keep the RRs and their signatures close together.

RFC 4035, Section 3.1.1, Including RRSIG RRs in a Response

  3.1.1.  Including RRSIG RRs in a Response

  When responding to a query that has the DO bit set, a security-aware
     authoritative name server SHOULD attempt to send RRSIG RRs that a
     security-aware resolver can use to authenticate the RRsets in the
     response.  A name server SHOULD make every attempt to keep the RRset
     and its associated RRSIG(s) together in a response.  Inclusion of
     RRSIG RRs in a response is subject to the following rules:

  o  When placing a signed RRset in the Answer section, the name server
        MUST also place its RRSIG RRs in the Answer section.  The RRSIG
        RRs have a higher priority for inclusion than any other RRsets
        that may have to be included.  If space does not permit inclusion
        of these RRSIG RRs, the name server MUST set the TC bit.

  o  When placing a signed RRset in the Authority section, the name
        server MUST also place its RRSIG RRs in the Authority section.
        The RRSIG RRs have a higher priority for inclusion than any other
        RRsets that may have to be included.  If space does not permit
        inclusion of these RRSIG RRs, the name server MUST set the TC bit.

  o  When placing a signed RRset in the Additional section, the name
        server MUST also place its RRSIG RRs in the Additional section.
        If space does not permit inclusion of both the RRset and its
        associated RRSIG RRs, the name server MAY retain the RRset while
        dropping the RRSIG RRs.  If this happens, the name server MUST NOT
        set the TC bit solely because these RRSIG RRs didn't fit.


Can my VPN provider see my browsing activities on SSL sites?

No, they can't, assuming you trust the certificate on the site.

However, your VPN provider can still monitor metadata that is not encrypted, such as DNS requests and IP addresses of hosts you communicate with. They could at least reveal on what domains you have possibly visited.


Is it safe to view a file on Google Drive?

Let's unpack this:
"... Can I safely view these types of files on a google drive (without downloading them)..."
When you view or edit a remote file, you are downloading it. You can see it only because it's on your computer. Depending on circumstances it may only be in memory, it may be written to a temp file, it may be in chunks if the file is exceptionally large, but it's on your computer.
"... images, mp4s, word, PowerPoints and pdf documents ... nothing executable and no programs ..."
Images like JPGs or videos like MP4s are not going to carry executable malware outside of torturous logic involving steg and third party executable malware. There have been some extremely rare exploits against graphic driver flaws in the past but the odds of encountering that are just about zero.
However there are a number of file types that are executable that might not seem like it and can carry malware . The old Windows ".wmf" graphic file contains an executable capability. So too might all Windows Office files like PowerPoint. Adobe PDF, while really convenient, has a very long history of many and continuing security issues with dangerous executable capabilities, that's why there's concerted effort industry wide to stop using PDF.
"...Can I safely view these types of files ... from an uninfected laptop or is best to use a Chromebook?"
I'm guessing you are referring to using a different operating system than Windows, under the assumption of Windows only malware? Using a different operating system will help provide a buffer, but cross platform malware is not unusual in scriptable mechanisms such as MS Office and PDF's.
How likely is it that you may encounter these types of malware I can't say. The safest way to handle it is to use a non-persistent OS that can't be infected past a power cycle. (Yes there are extremes of BIOS/GraphicCard/etc modifications but it's not a significant concern.)


Is the src of an iframe safe for user input?

No, a user-supplied <iframe src=...> is not safe.

The alert() in your example doesn't fire because the sandbox property automatically blocks modal dialogs (alert boxes). But since you have set allow-scripts, the JS code is still executed in the background. And because allow-same-origin is set, it is even executed on the same domain as the embedding page. Using these settings together makes the sandbox attribute useless because you're giving the sandbox full privileges.

As a proof of concept, just use another function, e.g. document.write():

<iframe sandbox="allow-scripts allow-same-origin" src="javascript:document.write(document.domain)">

Or add the allow-modals directive (which interestingly isn't currently documented):

<iframe sandbox="allow-scripts allow-same-origin allow-modals" src="javascript:alert(1)">

Be aware that instead of the javascript: scheme an attacker could also inject a data: URI:

<iframe sandbox="allow-scripts allow-same-origin allow-modals" src="data:text/html,<script>alert(1)</script>">

If your plan was to give the embedded page as few permissions as possible, you could have just left the sandbox attribute empty:

<iframe sandbox src="...">


PHP: decrypting a file directly to a stream using the defuse/PHP_encryption library

I tested out encrypting with the File class, then reading the file contents and decrypting with Crypto::decrypt(), however they are not compatible out of the box.

So I ended up writing a small wrapper class in the vein of your third idea -- read the plain file, encrypt the string, and write the encrypted data to disk.  It includes this function (note that $this->key() is loaded/unlocked elsewhere in the class):

use Defuse\Crypto\Exception as Ex;
use Defuse\Crypto\Crypto;

public function encrypt_file($source, $destination, $password = "") {
    try {
        if(is_file($source) === true) {
            $string = file_get_contents($source);

            if($password == "") {                   // Key object-based encryption
                if(file_put_contents($destination, Crypto::encrypt($string, $this->key), LOCK_EX) !== false)
                    return true;
            }
            else {                                  // password-based encryption
                if(file_put_contents($destination, Crypto::encryptWithPassword($string, $password), LOCK_EX) !== false)
                    return true;
            }
        }

        return false;
    }
    catch(Ex\EnvironmentIsBrokenException $e) {
        return false;
    }
}

Now I can read it with a file_get_centents() and a Crypto::decrypt(), and it's easy to dump the plain file back to disk if I really want to (which I generaly don't).


Combined-Dictionary attack with hashcat, for 4 words passphrases?

You're looking for hashcat's related tool princeprocessor, also by hashcat's author. It's specifically designed for multiword passphrases and similar "combination" work.

A killer PRINCE feature is that it does all of the combination work for you without having to store all combinations on disk (which is probably what you meant by "heavy"?)

princeprocessor also includes some hashcat rules that are designed to maximize GPU utilization by adding a variety of permutations.

Tip: tinker with very short wordlists and observe the output directly:

$ cat wordlist.txt
xenos
hashcat
prince
passphrase

$ pp64 --elem-cnt-min=4 --elem-cnt-max=4 wordlist.txt
xenosxenosxenosxenos
xenosxenosxenosprince
xenosxenosprincexenos
xenosprincexenosxenos
princexenosxenosxenos
xenosxenosxenoshashcat
xenosxenosprinceprince
xenosprincexenosprince

[...]
passphraseprincehashcatxenos
passphrasehashcatxenosxenos
hashcatpassphraseprincexenos
passphrasehashcatprincexenos

... and then once it's working the way you expect, pipe your output to hashcat using wordlist mode (-a 0) with your real wordlist.


How have DNS recursion attacks happened?

The basic "Mother of all Recursion Attacks" was published by Dan Kaminsky.

The basic summary is that you ask for a site and provide an answer with the appropriate query idea for the recursive server before that server gets the real answer.

The best resource I've got for you is An Illustrated Guide to the Kaminsky DNS Vulnerability which describes how the recursive system worked and why the flaw was possible.


Man-In-The-Middle (SSL) attack in my case

Assuming I understood you correctly and the phone app is doing the MITM, then :

1) Yes - it is generally used as a root CA to create (on the fly) new certificates for all visited web sites.  That root CA's public key must be trusted by the browser.

2) The private key is used to sign all the subsequent certificates (for the sites), that's why it is needed.  The MITM app generates the site cert using the private key and the browser verifies it using the public key.


Does it matter if my recovery media is read only?

Your concern is absolutely legitimate.

My disaster recovery plan involves a Linux ISO on a read-only drive which I use to nuke compromised machines from orbit before booting on standard writable media. The machine gets nuked from read-only media (no way for malware to alter it), then is fully powered down, and finally started back up using writable media once the malware is believed to be gone (firmware attacks are excluded).

If for some reason write-once media such as optical discs aren't an option, you could try booting over the network from an up to date machine with a proper firewall configuration (that drops anything other than the required DHCP and TFTP packets).

Another solution is to simply disconnect the hard drive of the machine, boot from whatever writable media you use, and connect the drive once the machine is started off the install media. Assuming the reinstallation image is up to date, there shouldn't be too much risk of malware from the drive somehow compromising the reinstallation system and writing back on the reinstall media.


What should I know to prevent relay attack on NFC?

I would stop focusing on 'relay' and do more research into MITM or man in the middle attacks. A relay is essentially just a MITM. Also initially I may even back off of NFC and just study MITM attacks on something that is more thoroughly documented, such as regular MITM over tcp.

When ever I am having trouble wrapping my head around a particular topic I try and create a lab to accomplish this. Research how to implement MITM attacks, specifically with NFC. As you work through that problem you will become intimately familiar with the concepts of the attacks as well as the protocols involved in NFC


If a company wants to store, transmit or process credit card payments they must provide the information the QSA requests. If they deny access to this information, they can be denied the use of VISA and Mastercard payments - which can put a company out of business very quickly!

When I have run pre-PCI audit readiness engagements, I will want full information about every part of the payment data pathway, including physical controls, network infrastructure, team access, authentication, encryption, storage, 3rd parties etc.


How to properly disclose a security vulnerability anonymously?

Trying to go trough a third-party might help in this case.

One of the main company in this area is the zero day initiative. You could probably report your flaw to them or another third-party. Depending on the importance of this flaw, you might receive monetary compensation for reporting the flaw.

Those company usually have way more connections and leverage than an average independent person.


How to convert a pcap file to a raw file?

If you want just the ASCII hex dump of all data and nothing else, then you can simply pipe the output of tshark through sed:

tshark -x -r mydata.pcap | sed -n 's/^[0-9a-f]*\s\(\(\s[0-9a-f][0-9a-f]\)\{1,16\}\).*$/\1/p'


How do I enable support for Cryptographic Message Syntax (CMS) in OpenSSL on OS X?

Answering my own question, as I can't find this documented anywhere.

The problem here is that the OpenSSL build bundled with OS X doesn't come compiled with CMS supported. In order to enable CMS support you will have to compile your own version of OpenSSL.

First, clone the OpenSSL Github mirror:

git clone git@github.com:openssl/openssl.git

Checkout a stable version, for example 1.0.2:

cd openssl
git checkout OpenSSL_1_0_2

Configure the compiled to enable CMS support:

./Configure darwin64-x86_64-cc enable-cms

Then make and install openssl:

make
make install

If everything goes well you should now have your selected version of OpenSSL installed at /usr/local/ssl/bin/openssl. When running /usr/local/ssl/bin/openssl cms you should see the following:

/usr/local/ssl/bin/openssl cms
Usage cms [options] cert.pem ...
where options are
-encrypt       encrypt message
-decrypt       decrypt encrypted message
(...)

Note that this will not override your bundled openssl installation, so you will either need to modify your path or use the binary directly.


iOS permissions for 3rd party app developers

iOS has a relatively simple permissions system for applications.

Applications have no access to the mail application, but they can access data from the native calendar and contact applications, though only if this permission is enabled in-app, and can be disabled from the start menu:

So basically, they can access location, contacts, calendars, reminders, photos, bluetooth, microphone, motion activity, and various linked social media accounts (linked through the settings app), but only if the end user agrees to it, and this can be disabled. (I assume you're used to android, where the app can only be installed if all permissions are granted.)


How does RealVNC Enterprise Know My System Credential?

It does NOT. Allowing you to login using your system credentials does not necessarily mean that RealVNC knows them. It means RealVNC asks the OS to do the authentication for it. Your password is never saved on your hard drive and even your OS is not aware of it, it's the hash of your password that is saved and used to verify that you are who you claim to be. The hash can't be reversed and your password can't be retrieved by RealVNC or any other program.


Can a secure invitation link be sent client-side only?

First, email is not secure. If you need strong security, you can't use email. Email can be sent on the wire unencrypted, it is unencrypted by interim mail servers, and potentially stored in the clear in the user's mailbox. You can google or look on this site for more info about email security.

So let's assume that you decide you can live with the insecurities of emails...

Typically the point of sending a verification email is to verify the user's email address. You cannot do this from the client as the user will be able to capture the link and use it without proving that they have to the email.

In short, I see no point in emailing the link from the client. Either you don't need to verify the email address, in which case don't bother with the email. Or you want to verify email address, in which case you must send the email from the server.


Storing a password securely as part of a webservice

If this is really for Dropbox, don't.  Dropbox has an API and OAuth.  Use Dropboxe's OAuth provider to get an OAuth token for the user instead, and you can store that. Do not take, or store the user's credentials.

If it is for a service that does not expose an authorization provider, and you do actually need to store the credentials on the user's behalf, you must do so very carefully.  Preferably they'll be stored in a separate service, with only authenticated sessions being presented back to your main application to reduce the attack surface area.  The credentials themselves should be stored in an encrypted format, and the encryption key should be stored as securely as possible, preferably in an HSM.

When you have data as valuable as authentication credentials for third-party services, your duty of care to protect those assets is very, very high.  Defense in depth is going to be critical, as is limiting access, logging and monitoring, and detailed threat modeling to understand the scope of your attack surface.


Can an attacker spoof an IP address to access my .htaccess protected file?

Remember that TCP/IP requires 2-way communication. Yes, someone can spoof an IP (with difficulty), but in doing so, they break the ability to receive replies.

Spoofing an IP is usually better suited to "fire-an-forget" scenarios like DDoS.


Would saving GPG and SSH keys as another user improve security?

I don't see the point in this measure. When you have an untrusted application you should rather run it under a special unprivileged user. Otherwise it would be able to detect how you accessed the files when you need them at some point.


PCI DSS compliant method to receive card data for a merchant with no electronic storage

The following a some best practices for storing paper with CHD in a compliant way. Note: this only addresses handling and storing the paper, not how the CHD is received in a "non-secure way."

Establish a record retention policy. The policy should state what is being stored, how it will be stored, how long it will be stored for, and the disposition of the paper at the end of the retention period. The policy should follow the DSS with regards to not storing CHD after authorization, cross cut shredding, etc.
Establish a record retention procedure. The procedure should outline the steps to follow to meet the requirements of the policy - particularly how the paper is to be handled and destroyed.
Establish a clean desk policy where papers with CHD cannot be left on the desk when a person is not at their desk.
Think through the entire lifetime of the paper with CHD - printing, movement, storage, sitting on desks, before authorization, after authorization, disposal, etc.
Operationally, here are some tips:

Have a locked cabinet with defined people with the key to the cabinet.
After authorization, black out the PAN with a thick magic marker. If the paper is no longer needed after authorization, shred it. If the paper is needed, store it in the locked cabinet. Sometimes people will even photocopy the paper after redaction (and shred the original) to fully get rid of PAN.
In the locked cabinet, have a tracking sheet to track when paper what put in and when it was removed and destroyed. I have seen it where one day's papers are in the same folder in the cabinet. That streamlines applying the record retention policy since all the employee needs to do is grab the aged-out folder and shred the contents.
If a third-party shredding company is used, you will need to assure that the shredding company is PCI compliant.


By looking at the MySQL select syntax,  you can see that it support into outfile at the end of a query.  If you look at MySQL Insert Syntax,  you'll see that there is no reference to into outfile.   There is a good reason for this,  insert is modifying the database,  and a select is obtaining data,  and the into outfile is a modifier of where that data goes.  From a developer's perspective is no reason to give insert the ability to write to files.

However,  all is not lost. The ability to insert data opens the door for second-order code injection.


Cross-Device-Tracking on Facebook with partners like Amazon

Based on your clarification, I think that you were re-targeted based on your IP address and some personal/demographic qualities.
I assume you understand that if it happened on the same computer, or while logged in to your FB on both computers, it was simple retargeting - Amazon showing recent product searches as a FB ad to FB users who visited the same product in the past X days.
Since FB doesn't reveal its ad-serving algorithm, I can only guess here, so I apologize in advance for the opinion-based answer.
I do have experience with FB ads and met with their representatives personally more than once, when they demonstrated the FB ads features. These guys claimed that FB ad serving algo is a "black box" that uses a lot of data for ad matching.
In any case, depending on the products you were searching, you might have been retargeted based on your interests on FB in addition to your IP address and recognized as the user who searched Amazon.
For example, if you're a 16 year-old male, and you were looking for video games on Amazon on your parents' computer, the connection could be made on FB's back-end that it was in fact you, because you're probably connected to your parents' FB accounts, you're on the same IP, and the interest in those specific ads fits your demographic much more than that of your parents.
To me, this is the most logical theory. I hope it makes sense.
Here's some interesting reading material about how the advertising industry tackles cross-device tracking, and specifically this section could be interesting for your case:

There are two ways to establish user identity across devices, one far more exact – and therefore potentially more problematic from a privacy perspective – than the other.
The deterministic method relies on personally identifiable information (PII) to make device matches when a person uses the same email address to log into an app and a website, thereby creating cross-device linkage. As long as a user is logged in across devices, advertisers and publishers can use this unique identifier to target those users on multiple screens with near-perfect precision.

...

Probabilistic cross-device matching is achieved by algorithmically analyzing thousands of different anonymous data points – device type, operating system, location data associated with bid requests, time of day and a host of others – to create statistical, aka likely, matches between devices. For example, if a phone, a tablet and a laptop connect to the same networks or Wi-Fi hotspots in the same places every weekday, it’s safe to surmise that all three devices belong to a specific commuter.

To conclude, I think that FB is using a combination of both the deterministic and probabilistic methods to conclude you were the user on both machines and serve you Amazon's retargeting ads.


The way to safely print untrusted data in HTML is by replacing HTML-significant characters with character entities. (That is, you'd replace < with &lt;, etc.) I suppose this is what you mean by "HTML escaping".

Now, if you filter untrusted HTML that way, you can't trigger XSS with jQuery's html() anymore. E.g., this will just print plain text without markup:

$('#element').html("&lt;h1&gt;XSS&lt;/h1&gt;");

Also note that the recommended way to insert untrusted content with jQuery is text(), since you don't have to bother with your own filtering. This is safe:

$('#element').text("
XSS
");

See this JSFiddle for a demo.


how is this data accessible?

It's not. If your browser issues a request, including AJAX requests, it will include all cookies for the target domain in the Cookie header, even httpOnly cookies.1 However, your script can't access them since the headers Set-Cookie and Cookie are forbidden headers per specification and you can't extract them with, say, XMLHttpRequest.getResponseHeader('Set-Cookie').

  Does it mean I should be able to securely switch on this http only flag by default and not worry that frontend scripts will not be able to make requests?

With httpOnly cookies your script can still make authenticated requests, it just can't read the values of the httpOnly cookies which are sent along. Turning on httpOnly only breaks functionality if you explicitly handle the cookies on the client side.

1 sameSite cookies can be an exception.


How does a country block/censor an encrypted website (HTTPS)?

TL;DR: TLS only secures the content of a message. Not the metadata.

When communicating over the clear net, it's important to remember that there are some portions of a given communication that cannot be secured using standard technologies. Unless you use something like TOR, your ISP will be able to determine who you're talking to even if you're using TLS.

To use an analogy, imagine sending an envelope via the postal service. The contents of the envelope are completely inaccessible to anyone other than the recipient. Even if a postman were to somehow view the contents, they wouldn't be able to comprehend it (Perhaps you ran it through a Caesar cipher first? Hehe).

However, in order to have the postal service send it to the correct address, the outside of the envelope must be marked with a plainly readable representation of the destination address. If the postal service didn't want anyone to be able to send letters to "Joe Schmoe, 123 Fake street," then they could just not deliver any letters with that address.

Since the postal service can't read the contents of the message, they have no way to identify the intent of the letter. The only information that they have is the fact that the intended recipient is Joe Schmoe. They can't screen only the letters that they deem to be malicious; it's all or nothing.

Similarly, the IP protocol (the routing protocol that TCP runs on top of) has plainly marked "sender" and "receiver" fields. TLS cannot encrypt this for two reasons:

TLS runs on top of TCP/IP, and thus cannot modify parts of the packets that belong to those protocols.
If the IP section was encrypted, then the carrier service (ISP routers) would not be able to identify where the packets need to go to.

The firewall that your ISP or country is forcing all of your traffic through cannot inspect TLS traffic. They only know the metadata supplied by the TCP/IP protocol. They have also deemed that the site you want to access is more bad than good, so they drop all of the traffic to and from the site regardless of the contents.

There is a method to secure even the metadata of online communications, but it is slow and not very scalable. TOR hidden services are one attempt at implementing this. Of course, hidden services only work within the TOR network, which can only be accessed by first connecting to a machine over the clear net. This means that the ISP or firewall still knows that you're proxying your data through the onion. No matter how you try, you will always leak some metadata. If they wanted to, they could reset all connections to TOR nodes in addition to the site they're currently blocking.

If you are trying to establish a direct connection to a specific IP through a firewall, and the firewall has explicit rules to kill any traffic to or from that given IP, then connecting to that IP directly will always be fruitless. You will have to connect to it indirectly, either through TOR, a VPN, or some other proxy service.


How to prevent users from executing commands through browser URL?

It's a command injection attack in which :

  the goal is execution of arbitrary commands on the host
  operating system via a vulnerable application. Command injection
  attacks are possible when an application passes unsafe user supplied
  data (forms, cookies, HTTP headers etc.) to a system shell. In this
  attack, the attacker-supplied operating system commands are usually
  executed with the privileges of the vulnerable application. Command
  injection attacks are possible largely due to insufficient input
  validation.

There are many strategies to mitigate or to avoid this kind of attacks like:

Do not “exec” out to the Operating System if it can be avoided.
Validate untrusted inputs.(Character set,Minimum and maximum length,Match to a Regular Expression Pattern...)
Neutralize meta-characters that have meaning in the target OS command-line.
Implement “Least Privilege”

You can find somes here and have a look at this cheatsheet from OWASP for further details.


is it possible to issue a sub-CA and trust it only?

Yes, and in fact this is generally how risk gets minimized in large deployments.  What you're describing is a two-tier PKI hierarchy.  Typically, it starts with the ROOT CA at the top, which serves as the "trust anchor," or the one CA which everything in your domain is going to ultimately trust.  Typically, this machine NEVER touches a network in its lifetime. You'll have it generate a self-signed certificate (in the process, it will have generated its own private key with which to sign other certificates).

Then you build what will be a suboordinate (or "online") CA. This one can be network-attached.  Generate a key pair (Certificate Signing Request), and place the resulting CSR on some removable media.  Sneakernet that media onto the ROOT CA, and have it sign the CSR.  The resulting certificate is what gets installed back on the suboordinate CA.

Meanwhile, all your client machines should have the public certificates of each CA (the ROOT CA at minimum) in its "Certificate Trust Store."  This is the only way clients will know what to trust.

From this point, you could create as many suboordinate CAs in the same manner described above, and assign them to support whatever you wish... a department, a line of business, a type of device or user account object, a data classification, external partner trust relationships (you can create a sub-Ca specifically for the purpose of signing another organization's sub-CA to create a limited realm of trust between the two networks).


It seems that you are not actually asking about 3rd party attacks like CSRF or XSS, but actually worried that the authorized user will rewrite the JavaScript or send a query by hand.

There is no protection against that, unless you're willing to try extraordinary measures to lock the user out of their own computer and browser.  See e.g. Is AJAX fundamentally insecure?


Determining how my Wordpress website was compromised

I will try to explain how such and similar hacks happens. They are really prevalent and at some point of time I was puzzled with something like this: who can possibly reply to an email that claim that some nigerian king wants to share his 5mln$ and needs your help, and in such a case why spammers are sending these spam.

First of all one have to understand that this attack was not tracking particular user or particular site. Most probably the person who decided to do the attack had no clue about the site beforehand.

He googles something like this: vulnerability in wordpress, and gets tons of results. For example this is the list of vulnerabilities, but this is too much text and I do not have time too read it. So let's see something easier. Ok, this sounds like a deal and the threat looks amazing:

  The utility only does a partial match on hostnames allowing hackers to
  upload and execute arbitrary PHP code in your timthumb cache directory

http://markmaunder.com/2011/08/02/technical-details-and-scripts-of-the-wordpress-timthumb-php-hack/

It has even some ideas how to exploit it, but lets just look at the google query: how to exploit timthumb.php . The link with a title technical details sounds like it can give you a technical detail (actually it is not, but I will stop writing here so that it will not look like I am telling how to break something).

  The ability for a site visitor to load content from a remote website
  and to make the web server write that remote content to a web
  accessible directory is the cause of the vulnerability in timthumb.php

amazingly convenient.

So the person is testing vulnerability on his machine and after it gives him a possibility to upload an arbitrary file on your machine it will upload something bad. And than run it. Ok he has done it on his machine, but how he found this guy?

Answer is simple: attacker was not looking for it, he was just looking for every site that used timthumb.php. After getting them he tries every site and chances are big that one of 10 sites would have this exploit.

I am not claiming that the writer's site was hacked in such a way but most probably in similar way.

I have written this with one thing in mind - give the idea how is it done, not to tell how you can do it (in this case it is written really badly)

Another reason for writing it is to tell what can you do - update your core as often as possible. Check for bugs and exploits.

The good thing is this sort of attacks is done by people who has no idea how to do create it. Nevertheless I am a programmer, but I have never even used wordpress and it took me less then an hour to write the post and search for exploit.

So most of the people like I have just describe are like monkeys - they have no idea what are they doing (they just copypaste something). They see something on site, they want to look like hackers and they are really proud if they will be able to do. And if they will not succeed with simple instructions - they will just move to next possible victim.

Sorry if my answer looks unstructured and stupid. If you think you can improve it - I would be glad

EDIT: Please patch your website ASAP. If you feel the desire to show the community what the page exactly is; save the html file as a txt file. This way it doesn't execute anything on more computers.  Your blog has been marked as a phishing website, firefox prompts and suggests "getting out of here".


How can I make it more difficult for a user to create multiple accounts?

There is no effective way to prevent a dedicated attacker from creating multiple accounts.  No matter what you do, the attacker will still be able to create multiple "sock puppet" accounts.  The best you can do is raise the cost of creating additional accounts.

One approach is to require the user to provide a mobile phone number, authenticate the user's phone number (by calling it, speaking a random auth code, and having the user enter in the auth code into the web site, like Google Voice does).  Then you can ensure that each mobile phone number is linked to at most one account.  This does not prevent creating multiple accounts -- an attacker can still buy multiple disposable phones, for instance -- but it raises the attacker's costs and might be enough to convince him/her to bother someone else instead.  The disadvantage is that it prevents some people from using your site, e.g., if they don't have a mobile phone, or if they are not willing to share their mobile phone number with you (people will probably be reluctant to share their mobile number with a site they don't already have a very good trust relationship with).

Another possible approach is to require the user to authenticate with a Facebook account, and rely upon Facebook to check uniqueness.  This is also far from perfect: people can still create fake Facebook accounts.  The disadvantage is that requiring people to log in via Facebook may prevent many people from using your site and is bad for privacy.  It is unfriendly to people who don't want to log in with Facebook, don't use Facebook, or don't want to share their Facebook information with you.

See also How to prevent cheating (extra votes) in online contests? for more discussion about a variety of mitigations.


You can use OpenSSL to check that easily:

openssl s_client -connect www.myhost.something:443 -tls1

If that succeeds, tls version 1 is enabled.


Differences between Burp request and Browser - Has different responses

Intercept the request using a browser and send that request to the comparer.  Then take your original Burp repeater request and send it to the comparer.  Compare the two. If nothing is different, then you must have something set that updates requests.  I know there are options to automatically update content-length and things like that.


How does end to end encrypted emails work?

Whatever can decrypt can get hold of the plaintext. For encrypted email that includes "the server" or not, depending on the setup, which is not clear in the question.

With what we can imagine of the setup, for sure the plaintext is available not only to the user, but also on the screen, and in the computer connected to that. The plaintext is thus vulnerable to whoever can see the screen, tap its cable, penetrate the user's computer, or decide the programs it runs in the first place. That minimal chain of trust needs not extend to "the server" (as in say an IMAP server on which the emails are stored at rest), but it can extend to that, and sometime does. The question does not allow to tell, in particular because it does not specify what "the frontend of the email service" is.

The conceptually simplest and (thus) safest way to practice email decryption is that it is carried on the recipient's own trusted computer, which is the only machine using the user's private key. In this case "the server" can not see the decrypted email. In the basic form of that, encrypted email really is a an attachment, extracted and deciphered by a local program (e.g. GnuPG), and displayed. That can be integrated in the email client program (e.g. Thunderbird, or Outlook-the-user-side-program), perhaps thru a plugin. And that can be integrated in the email syntax so that the encrypted email does not appear as an attachment. Each step away from simplicity comes with potentially decreased security; that's one of the lessons of efail (archive; main site is currently down, because security is hard to conciliate with functionality).

Setups in which the server can intercept the decrypted email include anything where the user interface is a standard web browser. Adding a plugin handling the decryption locally with a local private key, perhaps a Smart Card or Trusted Platform Module can be a step in the right direction; but that might also be mere security theater if the software orchestrating the flow of information comes from the server: the server can still send a modified software that will give access to the email. In practice, whatever can decide how decryption is performed can get hold of the plaintext (with few exceptions not found in common practice: like there is a data diode in place to prevent the decrypted plaintext to flow back to the server).

When the user is using a web browser or a dedicated program of unknown origin and closed design or/and source, it is in practice next to impossible to tell if "the server" can get the decrypted email, thus the rational action is to consider that possible.


Does prefetching/preloading in web browsers pose a security risk?

Pre-fetching as I understand it in Google Chrome performs things like DNS lookups and static content caching. In order to determine what static content to download, some parsing of the HTML document it pre-fetches must be conducted and it is known that browsers have been vulnerable to malicious HTML payloads in the past (Internet Explorer CSS and HTML parsing bugs leading to shell-code execution).

One must then reasonably conclude that yes, pre-fetching does pose a security risk to users in the sense that it downloads and processes essentially code from pages that you may not have intended it to.

I am presuming that the pre-fetched processing logic still enforces the same-origin policy requests but again depending on how separated the pre-fetching logic is to ordinary page loads there is a possibility a vulnerability exists here which only occurs when a malicious page is pre-fetched rather than visited directly.

Given the somewhat limited benefit of marginally faster page loads, I'd recommend if there's a chance you're frequently visiting pages that reference known malicious pages (e.g. because you're doing security research) it is worth disabling pre-fetching.


Maybe try this to show important files in your explorer?


The specific question is SQL injection with AND 1=1 and not OR 1=1. There is a big difference here in what the OP is asking about. If I were your teacher and you provided me with JonathanMueller's answer you would get a lousy grade as you dont understand the question.

AND 1=1 is usally used in blind SQL injections. This is when you have to determine between a true or false state from the result of the application to make out what the actual result is. You don't get data listed out in the result, the only thing returned is a state of change.

If you try to exploit a Blind SQL injection with OR 1=1 you will fail because the primary use of OR 1=1 is to create an always true statement in order to get the most data out of the database or to force a true statement in the case of a login script being exploited.

A practical blind SQL exploit example:

  We use our example: http://www.site.com/news.php?id=7
  Let’s test it:
  http://www.site.com/news.php?id=7 and 1=1 <--- this is always true and the
  page loads normally, that's ok.

  http://www.site.com/news.php?id=7 and 1=2 <--- this is false, so if some
  text, picture or some content is missing on returned page then that site is
  vulnerable to blind sql injection.

Another example where you try to figure out MySQL version:

  http://www.site.com/news.php?id=7 and substring(@@version,1,1)=4
  This should return TRUE if the version of MySQL is 4. Replace 4 with 5,
  and if query return TRUE then the version is 5.

Examples taken from: http://www.exploit-db.com/download_pdf/14475


Is it even possible to hack a television channel?

Hacking a television station is hard.  Most of the broadcast infrastructure isn't connected to the Internet, making outside intrusion difficult or impossible.

Let's say you want to hack your local news station.  Problem #1 is that their equipment isn't connected to the Internet -- it's quite possible that they're still using a bank of Betamax machines for ads and canned programs, and direct-wired connections for live television.  Problem #2 is that the broadcast antenna has either a hard-wired connection to the studio or a narrow-beam microwave connection.  Taking over their broadcast pretty much requires a physical break-in.

Okay, how about taking over a satellite broadcast?  These days, those are usually encrypted to prevent unauthorized people from listening in, so you can't replace the official uplink with your own, even if you can get a powerful enough transmitter into a location that the satellite is listening to.

The most common form of "hacking" is pirate television, where someone sets up an unauthorized transmitter and broadcasts, possibly overwhelming the signal from an authorized user of the channel.  That said, other forms of hacking do occasionally occur.


Why is "\000" added to the end of passwords prior to hashing with bcrypt?

I continued my own investigation...

\ is an escape character in java, but one thing I didn't realise is that it can escape more than one character. In this case, it escapes all three zeroes, thus adding a NUL character onto the string.

This turns into an extra byte on the end of the UTF8 array, with value 0. This is presumably used by the algorithm to identify the end of the password as it gets chopped into pieces and re-organized.

(This is enough to make me satisfied, but I won't accept my own answer for a while in case anyone can provide any more/better information than this in their own answer)


My MP3 file is blocked, but still playable?

The screenshot indicates that the Windows Attachment Manager has identified what it considers a possibly dangerous file from an external source and marked it. See http://support.microsoft.com/kb/883260 for information on what the Attachment Manager is and how to configure it.

The Windows Attachment Manager will mark many types of files that could possibly be a risk (without analysing the content) based on where it originated from. If you are just playing an MP3 you probably didn't even get a warning because of the way you are using the file. However if you had an .exe file instead Windows would warn you before it allowed it to run.

The additional stream information that "tags" the file as originating an external source will be copied around with the file in most circumstances (it will not if copied to some file systems such as FAT).

Ideally if you trust the source where the file originated from then you can unblock the file. Otherwise leaving the file blocked will not prevent access to the file however in some circumstances you may be presented with a warning before Windows allows the action.

Hope this helps.


Not natively, no. You would have to have some 3rd party authentication mechanism that loads up a second account when a different password is entered.


Can one tell if a password guess was close by the hash result?

No, you cannot determine how close you guessed looking at the hash. A hash function is designed with this in mind: one single changed bit on the input must change a lot of bits on the output. Its called Avalanche Effect.

Bellow are SHA1 hashes for some of your example passwords:

cbfdac6008f9cab4083784cbd1874f76618d2a97 - password123

b2e98ad6f6eb8508dd6a14cfa704bad7f05f6fb1 - Password123

2b4bfcc447c3c8726d26c22927a68f511d5e01cc - password124

115b55dcc1cd9a0dfdd60c120e83eaf658c45fc6 - right horse battery staple

abf7aad6438836dbe526aa231abde2d0eef74d42 - correct horse battery staple

A single bit change will completely change the hashing result. In fact, in an ideal case for every bit of input change every bit of output will be changed with a 50% probability.


Internal storage scheme for storing private keys inside an HSM

Every HSM will be a unique implementation.

I know that the IBM PCIe Cryptographic Coprocessor stores master keys inside the HSM, which are used to decrypt the keys that are kept encrypted in an external database.  The older version used 3DES to encrypt the keys; I don't know if V2 still uses 3DES or if they're using AES now.  Tampering with the HSM (or even violating its environmental envelope of temperature and humidity) securely destroys the internal keys and certificates, as well as rendering the HSM itself physically inoperable.

Inexpensive HSMs, such as a PIN pad you'd find at the grocery store, maintain their key state in battery-backed RAM.  Note that because PIN pads are out on countertops where they can be stolen or tampered with, they aren't trusted with a "master" key that's the same for all PIN pads.  Instead, they follow a key generation protocol called Derived Unique Key Per Transaction (DUKPT).  DUKPT specifies that each pad has a unique key injected at a secure facility before being shipped to the stores.  The PIN pad's unique key is derived from the system's base master key and the PIN pad's serial number, and DUKPT implements a "future key" generation scheme, which continually rotates forward with every use, destroying the old keys as it goes.  Attempting to violate the case will result in the CPU quickly scrambling the RAM and then cutting power to it, wiping the future key state.

I'm sure other HSMs have different variations on the theme, but they all behave in a similarly self-protective fashion.


How to generate self-signed certificate for S/MIME with usage 'signing' only, like DOD uses

Several of the OpenSSL utilities can add extensions to a certificate or certificate request based on the contents of a configuration file.

Key Usage

Key usage is a multi valued extension consisting of a list of names of the permitted key usages.

The supported names are: digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign, encipherOnly and decipherOnly (meaning of each name I'll leave for you)

Extended Key Usage

This extensions consists of a list of usages indicating purposes for which the certificate public key can be used for.

These can either be object short names of the dotted numerical form of OIDs. While any OID can be used only certain values make sense. In particular the following PKIX, NS and MS values are meaningful

 Value                  Meaning
 -----                  -------
 serverAuth             SSL/TLS Web Server Authentication.
 clientAuth             SSL/TLS Web Client Authentication.
 codeSigning            Code signing.
 emailProtection        E-mail Protection (S/MIME).
 timeStamping           Trusted Timestamping
 msCodeInd              Microsoft Individual Code Signing (authenticode)
 msCodeCom              Microsoft Commercial Code Signing (authenticode)
 msCTLSign              Microsoft Trust List Signing
 msSGC                  Microsoft Server Gated Crypto
 msEFS                  Microsoft Encrypted File System
 nsSGC                  Netscape Server Gated Crypto


Security Implications of Microsoft BITS - Background Intelligent Transfer System: Use, Abuse, Limit & Remedy?

I am wondering about the Security Implications of BITS being used and abused by legitimately and wrongful ways?

BITS by itself does not provide any kind of security. It is just a service to provide background up- and downloads and any kind of security must be added by using the relevant protocol (i.e. http vs. https) or validating the transferred content in the application (i.e. signatures).

There are no special privileges to use BITS. So it is possible for malware to use BITS too and this is also used in practice. For more information do a simply search or see for example Malware Lingers with BITS:

  Malware authors and intruders have abused the service since at least 2007.


MITRE's UEFI 'Extreme Privilege Escalation' and HP's SureStart

By contacting one of the authors I was able to get a response:

HP was allowed to get on stage during the presentation to discuss their vulnerability response, in the interest of the neutral stance MITRE holds. The authors have not evaluated HP's SureStart and their opinion can be summarized as: "we'll believe it when we evaluate it".


What is a good way to authorize a client at a time to perform an action through websockets?

Use Method 3 and make sure to use TLS (WSS protocol).

If one user = one websocket connection, this is enough.

If you want to handle reconnects or want to authenticate some users, generate a random id for each user and transmit this using https. The websocket client sends the id on connect to identify itself.

TLS protects against man in the middle attacks for HTTPS and WSS.


How are "Certificate Signing" key usage certificates restricted to what domains they can sign?

You have just shown why operating a CA is a position of responsibility, and why manufacturers of operating systems and web browsers limit the list of trusted CAs to around 100 world-wide by default.

When a CA delegates signing to a subordinate CA, the parent CA will typically impose name constraints or other policy constraints on the subordinate CA (for example, a subordinate CA descending from "US DoD CCEB Interoperability Root CA 1" may require the issuing CA to only sign Machine Authentication certificates if the SubjectCN and SubjectAN entries end in ".mil"). The parent CA may also limit by policy the chain length, preventing a subordinate CA from delegating additional subordinate CAs.

Much of this is documented and curated as standards and best practices by the CA/Browser forum. Additionally, Entrust's whitepaper about peer cross-signing of CAs has some interesting and accessible information about policy constraints.

Hope that helps.


Yubikey for signing efi images, could not find token

I just managed to get it working:

In strace I saw that pesign was looking for $CERTDIR/libnssckbi.so, but doing ln -s /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so $CERTDIR/libnssckbi.so didn't work, so to solve this I linked with opensc-pkcs11.so:

ln -s /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so $CERTDIR/libnssckbi.so

And now it finds the token. Please, let me know if there is a better solution (as this doesn't seems ideal).

Also, my argument in pesign ... -c "efi-cert" ... was wrong, as I should use the label in the token and not the one I gave to the certificate when including it in the certdir.

Executing the following revelled that the right label was "Certificate for Digital Signature" instead of "efi-cert":

$ pkcs11-tool --module=/usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -O
Using slot 1 with a present token (0x1)
Public Key Object; RSA 2048 bits
  label:      SIGN pubkey
  ID:         02
  Usage:      encrypt, verify
Certificate Object, type = X.509 cert
  label:      Certificate for Digital Signature
  ID:         02
Data object 27638640
  label:          'Card Capability Container'
  application:    'Card Capability Container'
  app_id:         2.16.840.1.101.3.7.1.219.0
  flags:          <empty>

Data object 27637904
  label:          'Card Holder Unique Identifier'
  application:    'Card Holder Unique Identifier'
  app_id:         2.16.840.1.101.3.7.2.48.0
  flags:          <empty>

Data object 27638000
  label:          'Unsigned Card Holder Unique Identifier'
  application:    'Unsigned Card Holder Unique Identifier'
  app_id:         2.16.840.1.101.3.7.2.48.2
  flags:          <empty>

Data object 27638096
  label:          'X.509 Certificate for PIV Authentication'
  application:    'X.509 Certificate for PIV Authentication'
  app_id:         2.16.840.1.101.3.7.2.1.1
  flags:          <empty>

Data object 27636560
  label:          'X.509 Certificate for Digital Signature'
  application:    'X.509 Certificate for Digital Signature'
  app_id:         2.16.840.1.101.3.7.2.1.0
  flags:          <empty>

Data object 27636656
  label:          'X.509 Certificate for Key Management'
  application:    'X.509 Certificate for Key Management'
  app_id:         2.16.840.1.101.3.7.2.1.2
  flags:          <empty>

Data object 27636752
  label:          'X.509 Certificate for Card Authentication'
  application:    'X.509 Certificate for Card Authentication'
  app_id:         2.16.840.1.101.3.7.2.5.0
  flags:          <empty>

Data object 27636848
  label:          'Security Object'
  application:    'Security Object'
  app_id:         2.16.840.1.101.3.7.2.144.0
  flags:          <empty>

Data object 27636944
  label:          'Discovery Object'
  application:    'Discovery Object'
  app_id:         2.16.840.1.101.3.7.2.96.80
  flags:          <empty>

Now I can execute the following:

$ pesign -i bootx64.efi --export-signature bootx64.sig --sign -d sha256 -t "PIV_II (PIV Card Holder pin)" -c "Certificate for Digital Signature" -n $CERTDIR
Enter Password or Pin for "PIV_II (PIV Card Holder pin)":
Enter passphrase for private key:


Coming from a person that is in the middle of PCI compliance issues right now .. no. You don't need to be pci compliant if you are using a third party service to input and handle your credit cards. One if my smaller clients runs an commerce site specializing in jewelry.

As long as no cardholder data (the PAN, magnetic strip, PIN block, etc) is entered (and especially stored) on your systems you let the vendor that processes the payment handle all the burden.

To check if this is true you should only be handing a specific amount of funds owed or an itemized list to your provider. If you are handing them any details of the transaction beyond this you will need to look at at least a basic compliance questionnaire.

Note that I'm not familiar with your vendor. If it is anything like PayPal this will be true.


Malicious(?) PHP / BASH Script. What is it?

It looks like a set of different malicious things to do when a system is compromised. The script is no more dangerous than the security issue that allowed it to be inserted in the first place. Consider it to be a remote controlling toolkit once the hacker got in.

Once installed it can rewrite itself or other files on the server to be this script, modified to it's current environment. Then tricks the visitor that triggered this script to be redirected to a different website. This script could be used for defacing or (considering it contains stats tracking) trying to generate income by tricking the user into viewing or opening ads and possibly more uses.


How do I control multiply-nested embedding of my iframe?

CSP frame-ancestors already does what you want.

Content-Security-Policy: frame-ancestors [...] checks the entire ancestor chain. If any parent document doesn't match the source whitelist, your document will not be loaded.

If your chain is top(child(grandchild)), this policy for grandchild would pass:

Content-Security-Policy: frame-ancestors top child

But none of these:

 Content-Security-Policy: frame-ancestors top
 Content-Security-Policy: frame-ancestors child
 Content-Security-Policy: frame-ancestors 'none'

X-Frame-Options: allow-from [...] only checks a single ancestor. The de-facto implementation in most browsers is that it checks the top origin but no origins in between.

If your chain is top(child(grandchild)), this directive for grandchild would work:

X-Frame-Options: allow-from http://top/

But none of these:

X-Frame-Options: allow-from http://child/
X-Frame-Options: sameorigin
X-Frame-Options: deny

The W3C CSP2 specification also explains the difference:

  7.7.1. Relation to X-Frame-Options

  This directive is similar to the X-Frame-Options header that several user agents have implemented. The 'none' source expression is roughly equivalent to that header’s DENY, 'self' to SAMEORIGIN, and so on. The major difference is that many user agents implement SAMEORIGIN such that it only matches against the top-level document’s location. This directive checks each ancestor. If any ancestor doesn’t match, the load is cancelled. [RFC7034]

(Source)


You shouldn't mess with the algorithm like this. I can't think about what the impact of this method is but it does scream insecurity. At the very least, it would allow an attacker to move roughly 256 times as fast since CRC is a relatively simple math function and then of course faster on the database part. You're a few whiteboard coding exercises away from somebody dumping all your passwords if they get DB access.

Instead, issue a token using a cheap function that is rate-limited per client address or client address prefix and require that token with the username and password. That will allow you to rate limit how often you perform the expensive password checking process.


Can a virus infect source code files with dangerous data?

Yes.  As early as 1990, Peter DaSilva had circulated a cautionary tale about a source code virus. It reads a lot like a design document for such a virus. I don't believe that one was ever implemented, or at least nobody I know of has confessed to trying it.

In 1989, the Usenix Association published Computing Systems Volume 2, Number 2. This had an article, Virology 101, by Doug McIlroy. That article walks you through writing a shell-script virus, which infects source code. I think that shell-script virus would work today, probably requiring minor syntax fix ups.

I'm not at all sure how you'd go about cleaning up a code base that had been messed with by some kind of source code virus.  If you had it in version control, you could revert to a pre-virus version, and then carefully construct patches to bring the code base up to date, but without the self-reproducing code of the virus in it.  Seems like a lot of work.


POODLE vulnerability in major social networking

Some portions of your question need to be clarified.  The SSL/TLS encryption is based upon the cipher suites supported by both the client and the server.  Not the certificates issued to each social networking site.  The certificates issued do not have a bearing on a website's vulnerability to POODLE.

The fallback to another SSL version is only performed if both sides don't agree on a cipher suite.  SSLv1 was never released.  The only browser I know of that supports SSLv2 is IE (at least up through IE9 this was true).  These versions of the protocol would still have to be supported by the server.  Server's do have SSLv2 support, but rarely enabled by default.

All that being said, social networking sites aren't "at risk".  The clients are at risk because its their credentials that can be decrypted.  Facebook will roll out patches/updates to their servers so that SSLv3 is disabled to protect their users, but the servers themselves aren't being actively compromised.


How I can enumerate all endpoints of an API?

From the outside, there's no generic method. A site can have as many (possibly obfuscated) endpoints as they wish.
You could, however, get lucky if there is an automatically generated site-map; it might just include a list of endpoints.

From the inside, it's possible. It can be labor-intensive, depending on how the site works. If you have access to the web server configuration, you can walk through it to find the endpoints.
For an Apache webserver, start with httpd.conf .
For IIS, you'll have to open the GUI and find the sites hosted by that IIS server, then find the endpoints on them.


Does a DDoS attack have other purposes beyond a lack of availability?

There are a few ways a DDoS can help in perpetrating extra villainies:

If the DDoS target is a security service (e.g. an intrusion detection system), then deactivating the service can allow easier break-ins. For instance, if a hole is found in an operating system, which allows for remote code execution, then a DDoS on the OS vendor's update site will delay propagation of the fix, thus allowing for a longer exploitation window.
The DDoS itself is likely to generate tons of logs which will make detection of malicious non-DDoS actions harder: log entries which would normally trigger alarms fly under the radar, because the IDS and the people who look after it are overwhelmed by the DDoS-related flow.
Since a DDoS threatens the continuity of business activities, some organization may apply emergency procedures which aim at maintaining the service at the possible expense of security. For instance, if a DDoS implies an overload of an email-antivirus, then the organization may decide to switch off the antivirus, so that emails flow again; but then, virus may enter more easily. Another case is an organization who switches to an alternate site which might not be as well protected.

See this previous question on the same subject.


understanding and getting over the SSL performance issue

When your website references 10 external files, these will not be loaded one after another. The users web browser will request them all at the same time and load them in parallel. That means the total time is 200ms for loading the HTML file and another 200ms for loading all the images, scripts, stylesheets etc. which are mentioned in it.

The RFC 2616 states that web browsers are only allowed to open two connections to each server at the same time, but nowadays all major browsers ignore this and allow a lot more parallel connections (how many varies from browser to browser and is often configurable by the user).


How to force "expensive calculation" when clients connect to my server?

I think this idea basically describes the proof-of-work concept as it is used in anti-spam setups or more popularly Bitcoin.

Proof-of-work is used to make the requester/sender perform a small computation to show it's authenticity, following the idea that spammers (including non mail related spam) will avoid such systems because it would cost them too much CPU power to send their spam.

I don't know of any implementation in "regular" http traffic though but it seems they definitely exist:

DOS mitigation using proof-of-work

Their implementation: common DoS attacks are based on the TCP protocol (the basis for HTTP traffic). The attacks abuse the three way handshake by sending SYN requests to the server without answering the SYN-ACK signals the server sends back. As is the main idea of a DoS attack, the server can only have so many outstanding requests and stops sending them to legitimate senders of SYN signals at some point therefore appearing offline.
By adding an extra layer in the three way hand shake via POW the TCP DoS is avoided because the additional computations required disrupt the intended DoS flow of requests. As only legitimate requests reach the server HTTP traffic can flow freely and because the extra computations required by the POW take only 0,2-0,3 seconds no real delay is experienced by the user.

proof of work approach using IP header

Also, this question might hold some relevant info


The page lists the affected systems and your windows 7 32bit is not included:

Affected
Avaya DefinityOne Media Servers
Avaya IP600 Media Servers
Avaya S3400 Message Application Server
Avaya S8100 Media Servers
Microsoft Windows 2000 Advanced Server SP1, SP2, SP3, SP4
Microsoft Windows 2000 Datacenter Server SP1, SP2, SP3, SP4
Microsoft Windows 2000 Professional SP1, SP2, SP3, SP4
Microsoft Windows 2000 Server SP1, SP2, SP3, SP4
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows Server 2003 Datacenter Edition Itanium
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Enterprise Edition Itanium
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows Server 2003 Web Edition
Microsoft Windows XP 64-bit Edition SP1
Microsoft Windows XP 64-bit Edition Version 2003 SP1
Microsoft Windows XP Home SP1
Microsoft Windows XP Professional SP1

Your "protection software" is showing you that someone is trying to attack you but since your system is not vulnerable but this attack you can simple ignore it.

In my opinion the software is crap. It should not bother you with this.


Has the POODLE SSL vulnerability ever actually been used?

The POODLE attack is actually very hard to pull off in real world conditions. A SecurityMetric blog post lays it out well:

  Here’s an explanation of how an attack would have to take place in order for an attacker to exploit POODLE and assume the user’s identity on the target site.

  The victim must be logged into a site using HTTPS (and the session cookie must not be expired)

  The victim must browse to another website over HTTP before the session cookie expires

  The attacker must write a custom JavaScript code to exploit POODLE. To date [OCT 22, 2014], no prepackaged tool has been published to exploit POODLE

  The attacker must inject ~5,000 requests in order to decrypt the session cookie

  Basically, this attack is extremely difficult because both the merchant and the user have to be vulnerable.

So to answer your question, this risk leans heavily to the theoretical side. I haven't found any news stories, blog posts, or security advisories saying that this exploit has been confirmed in the wild. POODLE has a high barrier to execution, and it's paid off.


It is of course possible to run a secure website without having a Content-Security-Policy.  There are, however, some reasons it makes sense:

First, if you configure it reasonably strictly, it's possible to make certain security problems, like cross-site scripting attacks, harder or nearly impossible.  This does typically require eliminating inline scripts and restricting external scripts to load only from trusted domains.
If you host user-generated content, such as user-generated SVGs, you may want to avoid that content from being used as a source of scripts or a generalized attack platform.  Since documents (including SVGs) loaded from a domain with a suitable CSP won't be able to use JavaScript, you may feel more comfortable hosting them.
You can also, more generally, require your pages to only function over HTTPS, since a robust CSP header will reject non-secure origins for loading external resources.  Thus, a page accidentally loaded over HTTP would be devoid of images, scripts, and functional forms.  While this would be a bad user experience, you'd at least avoid a lot of security problems in such a case.

I would say that now, in 2021, adding one is a best practice.  Many sites do not, but because CSP headers do provide defense in depth for a wide variety of problems, it would be prudent to add one.  I have no knowledge or interest in SEO and so couldn't speak to it, even it were on topic.


Are texted 2FA security codes deliberately easy to remember?

I have noticed this too, and I think it is a result of the human brain's tendency to apply patterns to random noise. This seems to be more common when specifically trying to remember a string of numbers.


How unwise is it to exclude WSL from Windows Defender?

It really depends what your risk profile is. Is this your personal computer or one you use for work? Are you behind a corporate network/firewall or just on your home network?
What's the worst thing that could happen if you did download a virus on WSL? Remember malware on WSL can still access the rest of your computer. While there isn't as much malware for linux (or WSL) it doesn't mean they don't exist so this is something you would need to take into account. If you are just downloading NPM/YARN packages you might be okay but it is still possible to inadvertently install malware from NPM packages.
Some options you could consider to mitigate the risk:

You could just do the odd malware scan to make sure you are okay
You could set up a linux VM on your machine and do your dev in there. This means any malware you might download during development wouldn't affect the rest of your machine.
You could set up some Linux VMs elsewhere to you (e.g. AWS EC2 instance). If you make sure they are immutable (aka you can easily kill one and start a new one and just continue) you wouldn't need any VMs locally, your local machine is safe and you can easily blitz the VM and start a new one if you wanted to.


What vulnerability is targeted by an HTTP referer starting with (){ :;};/bin/bash

This is targeting the Shellshock bug (which even has its own tag):

  GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution.

Affected are any systems which run a vulnerable Bash version and a way for an attacker to inject an environment variable. The most well known case is Apache which automatically sets certain environment variables from the request. You don't need a Bash CGI. See this article about Shell Shock Exploitation Vectors for an extensive list.

In order to defend against this attack you must update your Bash. To test if your Bash version is vulnerable, you may execute the following line from @EliahKagan's great answer:

x='() { :;}; echo VULNERABLE' bash -c :

See Everything you need to know about the Shellshock Bash bug or the corresponding CVE for more information.


How safe are USB internet keys compared to using a router/hub with a built-in firewall?

How does it compare using an USB internet key to being behind a router/hub that has a firewall?

With router/hub you probably mean the devices you use to get internet access through DSL or cable. The "firewalls" in these devices are nothing more than simple packet filters which don't offer (much) more than you can find in the built in firewall of todays windows systems. And by being only simple packet filters they don't offer any protection against today's most common threats, i.e. websites delivering malware and malware delivered within mails.

Thus the security of these router/hub and USB internet keys are similar in that they don't offer any relevant protection at all.

Note that few of the routers you can buy actually offer more protection by using external services and might block access to URL's based on externally provided blacklists etc. But these are usually added services which you have to pay for regularly, similar to a antivirus installed on the local machine.


What does Obama's phone say about Android and phone hardware?

The phone you are talking about is not the stock Samsung S4. As you can read in the article the cameras are removed, there is a special app store only and there are special apps on it. It also states that this phone was explicitly chosen because of the KNOX technology which includes secure boot and separation of work and private activities.

The reason this is done on a comparably old phone hardware is because the process to develop and especially audit such special solutions for a small market takes a long time.

And why did they not go with Apple? It is hard to tell, but if you develop such a system you don't want to develop it again after a year for new hardware and don't want to audit it again with each software patch. So it is important that you have hardware which is available for a long time and that you have access to the OS software to make adaptions independent from the original manufacture. And Samsung might have been just more open in this regard. And at the end the chips will be manufactured outside of the US in both cases and Samsung even makes at least part of the chips for Apple anyway.

By the way, in Germany they also use old Samsung hardware (S3) as the base for their secure phones (SiMKo3). But in this case they've made more adaptions to the OS, i.e. added separation with the use of the micro kernel L4.


malware attack on my website may have started a SOCKS server - please advise

IPTables!

It's the first thing I can think of.

This will happily let you block all outbound/inbound traffic that you don't want. So first you can configure SSH to be open on a non-standard port (ssh server config) and of course open port 80 (and 443 if SSL), for your inbound.

And only open port 80 and 443. Now, whilst this does not completely mitigate the risk, it's a tad more unlikely malware will go after the web ports to route it's proxy thru.

Since we are talking about WordPress. Always make sure you have everything up to date. Lock down the write accesses (ug WP autoupdate, who thought that was a good idea overrall?!).

.htaccess/blank index.html to lock down plugin folders that the author has overlooked.

Looking at the post you linked, that should help mitigate the attack in question.

Edit 1: It is of course always important to regularly audit your box(es) for running processes/open network ports.


Could mint.com be more secure, and if so, how?

From what I can see this appears to be an aggregator for financial services. For it to have any useful function, that implies it must, at least temporarily, store your account details and authentication credentials - in which case it is far from "read-only". That the providers then state the exact opposite in the security statement makes me think these are not people to be trusted with my account details regardless of how sophisticated their controls are.

Ramhound suggests that mint.com uses an oath like system - but that still uses a temporary surrogate token for authentication. Ramhound also states You never give Mint your banking information yet the first question in the FAQ is Why does Mint need my bank login information (username and password)?. The FAQ goes on to explain how mint stores this data.

Such aggregation does have an intrinsic value, and one way to add value to such a service would be to provide better authentication security than that enabled on most financial service providers websites - but obviously this is not the case for mint.com. There's also a question of whether such a provider is subject to the same legislative constraints as a source provider.

But unless you're the guy who writes the mint.com software, isn't a question of what it should be like pure speculation?


How to store private data both securely and publicly accessible?

I think you might be looking for a token based authentication system. They submit email address, the server produces a token and sends it out to them, they click on the link which must post the token back to your website in some form. The token is random and valid only for a limited amount of time ( say 15 minutes - think memcache ^.^) and can be refreshed based on user action. As for encryption, you could derive something from the email hash as a key and never keep the plain version of the email address. And refuse to reuse hashes in the new user phase..

As a side note, it sounds very scary using just the email to gain access. Mind you that most apps outhere that users will touch nowadays the first thing they will look at is the contacts. Therefore there's a very high chance someone already has a list of users and access.


Does zeroing a file on Android work similar to a regular HDD?

As was mentioned in the comments, Flash memory in mobile phones acts very similarly to SSDs, and therefore securely deleting a file is mostly impossible.

Quick summary: Flash memory can only be overwritten finite amount of times before it dies. To prevent parts of memory that are used often from dying, flash memory uses wear leveling.

That means when you delete a file, it only marks the space as free to be used for writing later, but it does not overwrite the file, as that would increase the wear unnecessarily. When you want to write data, it chooses a sector marked free that had the least amount of writes. It spreads the writes out in this way. This however means, that if you try to securely delete a file by let's say writing zeroes to it, the zeroes may be written to entirely different part of the memory (with less writes) and the file may remain.

Overwriting the whole flash memory also is not an option, as these memories have additional space reserved for leveling. So if you have 16GB memory, it may in reality be something like 20GB, the 4GB being in reserve to use for leveling when the memory is nearly full. More details here.


If compression doesn't compress Cookies (as per RFC it compresses only the body and cookies are a part of the headers), how do the CRIME attack are even possible?

CRIME does not work at the HTTP level but at the TLS level. The problem here is not the compression of the HTTP body like in BREACH but the compression of the complete connection at the TLS level. This way the compression includes also the HTTP  header which contains the Cookie.

For a more detailed explanation see CRIME - How to beat the BEAST successor?.


How make SQL select query without comma?

Lets say you need to retrive USERNAME,PASSWORD columns form USERTABLE.

In this example The USERTABLE has data as shown below

mysql> SELECT * FROM USERTABLE;
+----------+------------+
| USERNAME | PASSWORD   |
+----------+------------+
| ALICE    | ALICEPASS  |
| BOB      | BOBPASS    |
| ALICE2   | ALICE2PASS |
| BOB2     | BOB2PASS   |
+----------+------------+
4 rows in set (0.00 sec)

Now the SQL with out a comma (,) to retrive both username and password can be like below

SELECT * FROM (SELECT USERNAME FROM USERTABLE WHERE USERNAME>"A" AND USERNAME<"B")UT1 JOIN (SELECT PASSWORD FROM USERTABLE WHERE USERNAME>"A" AND USERNAME<"B")UT2 ON  UT1.USERNAME=UT2.PASSWORD OR 1=1

The output is as follows

mysql> SELECT * FROM (SELECT USERNAME FROM USERTABLE WHERE USERNAME<"B")UT1 JOIN
 (SELECT PASSWORD FROM USERTABLE WHERE USERNAME<"B")UT2 ON  UT1.USERNAME=UT2.PAS
SWORD OR 1=1;
+----------+------------+
| USERNAME | PASSWORD   |
+----------+------------+
| ALICE    | ALICEPASS  |
| ALICE2   | ALICEPASS  |
| ALICE    | ALICE2PASS |
| ALICE2   | ALICE2PASS |
+----------+------------+
4 rows in set (0.00 sec)

You should carefully put the filters at FROM USERTABLE WHERE USERNAME<"B".
If you put something like FROM USERTABLE WHERE USERNAME<"Z" you will probably hang the SQL server due to large join.

Just to mention if you think the database is very huge then polish your filters like USERNAME>"AA" AND USERNAME<"AF" so that a small set of data is being operated and its quick. In next iteration you can use USERNAME>"AF" AND USERNAME<"AL"  and so on.

And observe you got the combinations CROSSJOIN of usernames and passwords.
You will get  N X N rows .And you may consider rows at multiples of N like N,2N,3N etc for valid combination of usernames and passwords atleast in case of Mysql.

For some other database software may be you will need to try all the combinations of USERNAME,PASSWORD you retrieved.


Shall I need to use MD5 algorithm in both JavaScript and PHP for login authentication?

If we disregard the actual algorithm choice and consider the question: "Should I hash on both client and server side?"

Hashing in Javascript is completely unnecessary since the idea is to protect against the password being sniffed during transfer. But if that is a risk then the communication with the server is not secure which means that there could already be a man-in-the-middle attack going on.

This means that the javascript hashing algorithm could have been delivered by the attacker instead of the server. The algorithm could then for example send the password to the attacker.

So, no. You should not hash in the browser but instead use a secure connection to the server.


SSL certificate renewal and downtime due to revocation

Renewing an SSL certificate is the functional equivalent of generating a new certificate;  it is not a revocation, and the 'old' certificate will continue to be accepted as valid, assuming it has not yet expired.  There is no downtime/maintenance window requirement for its replacement.

Note however that due to the SSL SHA1 Hashing Deprecation, many certificate authorities (CAs) are moving quickly to phase out SHA1 in favor SHA256 by the end of 2016. This means that many CAs are making it easy to "re-key" existing SHA1-based SSL certificates, providing a quick regeneration of the existing SSL certificate, using the new SHA256 hashing algorithm, usually with a few clicks. GoDaddy, a major CA/domain registrar, implements this feature via their Starfield SSL CA service.

What is not often made clear, is that a re-key of a SHA1 cert to a SHA2 cert can include an implicit revocation of the existing certificate. The underlying process at Starfield to rekey a SHA1 certificate generates a revocation request, immediately rendering your current SSL certificate invalid. There is no documentation or warning on this important detail (!).  Many will assume requesting a re-keyed certificate is the equivalent of of a certificate renewal, when in fact it is a revocation request, plus the generation of the new certificate.  Imagine your surprise after clicking "re-key" and then downloading the new certificate, perhaps waiting for a later install, and that within a few hours your SSL endpoint become invalid.  Not fun. So be very careful on re-keying SHA1 certificates during the SHA1 deprecation transition period.

Another point to be aware of when migrating from SHA1 to SHA2 certificates, is to make sure and download and install the new CA intermediate certificate chain into your keystore at the same time. The SHA1 to SHA256 migration often means that the new SHA256 certificate requires new intermediate SHA256 certificate chains in your key store.  Not doing this can result in the invalidation of the base certificate.


Google Analytics: Hacked or Ghost Referers?

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

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


Why do evil twin attacks against WiFi use a captive portal?

They cannot create a twin WPA network without knowing the password of the legitimate one. So they usually disrupt the legitimate network, create an open network with the same SSID, and wait until some user connects to it by mistake.

After connecting, the user is redirected to a fake "Maintenance Mode" portal, or something like that, asking for the network password to proceed. As the vast majority of the users aren't tech-savvy, they will happily enter the password.

It takes only one user to disclose the password, and it's done. No need to capture lots of handshakes, rent an expensive rig on Amazon and spend a lot of money cracking a hash. Depending on the demographics of the users, a password can be obtained in minutes.


User mail certificates policy: Is expiration+renewal better than no-expiration+revocation?

The reason for the certificate's current invalidity is not relevant.
If Outlook, or any client software, presents a different conclusion regarding the validity of a signature from either type of certificate (expired, or revoked) then the software is broken and a bug report should be filed with the vendor.

If the signature was made while the certificate was valid, then the signature should (IMnsHO) be accepted as valid; if the signature was made after the certificate became invalid, then the signature must not be accepted as valid.
The tricky bit is establishing when the signature was made relative to the invalidation of the certificate. It's likely that there is no simple solution; I expect something like this proposed distributed timestamp mechanism or this longstanding timestamps-by-email service would be useful.

It's probably going to require more user education in any case.


Finding Security Loopholes and reporting ( web applications specifically)

Scanners are useful for a quick, basic security scan of a system to give indicators of vulnerabilities, their reports should never be trusted without validation and they often over report giving false positives.

It seems your question is geared towards bug hunting programmes / bug bounty schemes and if you just submit scanner reports to these programs you are unlikely to be acknowledged. In fact many schemes ban the submission of automatically generated reports if they even allow the use of  such a tool, remember they could do that themselves easily!

The people that are successful in these programs, those that receive bounties or are entered in the halls of fame use other tools and techniques to discover vulnerabilities that won't be exposed by a standard wide spectrum scanner.


How to add user entries with password field in LDAP over HTTPS?

Is it possible to get the userPassword as plain text, at the server-side, when the password is entered by an end user on client side with HTTPS being used ?

Yes. HTTPS is HTTP over TLS.  TLS stands for Transport Level Security, and, as the name implies, encrypts the transport layer.  That is, it's only designed to protect the data during its transfer over the network.

Generally there will be a TLS terminator (or SSL terminator) at the edge of your infrastructure; this software (or occasionally, hardware) decrypts the TLS encryption and passes the unencrypted underlying HTTP request on to the application server.  So yes, this is possible, and common.


Signing is pointless when you don't have a public key of the signer. You can't validate the signature anyway, so an attacker who wants to spam you with new accounts could just send a bogus signature. There are more efficient measures you can take like captchas or IP-based throttling.

Encryption, on the other hand, is never a bad idea. "Sign up" and  "Log in" require exchange of sensitive information, so they should be encrypted. Also, in the age of data-mining everything can be sensitive information, including that John Smith looked at the profile of user 29252 on example.com at 2015-08-19 17:02:03. So even seemingly harmless information should be encrypted whenever feasible. Making your whole website - both API and static content - https-only or at least https-capable is never wrong.


What is the risk of using http on an internal webserver?

By not using TLS you are giving up the integrity  and confidentiality. Your connection can be monitored or altered and there is nothing there to guarentee the endpoint is who they say they are.

An internal attacker can man-in-the-middle your http connection reading and altering data.
An employee could be targeted via phishing and a DNS rebind attack could be used against them to access this resource to get documents. As they are already within your network the request would circumvent your firewall. This however requires the attacker to have knowledge of your network.

Unfortunately we live in a time where you must assume you are breached so plan your security controls around this.


In a User Roles table is it better to identify users with an ID or username?

This isn't a security issue, it's a data management issue.

Usernames can, and do change.  That's why you use a meaningless identifier and foreign key relationship to ensure database integrity when you have a role table.

Any UI that adds or manages roles should hide the complexity of the ID vs the username inside it.