What is the difference between these SQLi queries? I was performing a Web Pentest and I found this when i was doing sqli in a search field:

' or  1=1--     returns 15 results
' or '1'='1     returns 30 different results
' or '1'='1--   returns 0 results

What may be the cause? I mean, what is the difference between those queries?

There are some details which I would have wanted for a better understanding, but I'm assuming that you are trying to send malicious SQLi in a search parameter.

Let me use an example that you are searching for the term 'shoes'

The web request for that might be: www.example.com/search.php?tag=shoes

The SQL query for that request might use LIKE. I have used LIKE specifically because you are targetting search box. It would be a rare case or a very app-specific case where instead of LIKE, a direct comparison (=) is done.

SELECT * FROM table_name WHERE searchtext LIKE 'shoes' AND SOME_CONDITION

Now let's insert your given SQL queries:

1) ' or  1=1-- -> This will convert the query to SELECT * FROM table_name where searchtext LIKE '' or 1=1 . Rest of the query gets commented out.

2) ' or '1'='1 ->  This will convert the query to SELECT * from table_name where searchtext LIKE '' or '1'='1' AND SOME_CONDITION . This causes a different query to execute than above. Depending on the condition or the subquery the results will be altered.

3) ' or '1'='1-- -> This will convert the query to SELECT * from table_name where searchtext LIKE '' or '1'='1 . Its an INVALID QUERY. This query should not execute as the quotes are imbalanced. The application might be handling exceptions, hence you are able to see 0 results, otherwise, you would have seen SQL error on your web app.


How to break out of URL context The OWASP XSS Prevention Worksheet recommends "URL escape before inserting untrusted data into HTML URL parameter values".

I don't understand how someone could break out of a URL context or inject a new subcontext to perform a XSS attack in a URL. As the browser interprets the URL, can certain characters be used to terminate the processing of the URL and force the browser to start processing a new injected URL?

http://somesite.com/about<terminating character>javascript:;alert("hello")

Can someone please provide examples of how someone would perform an XSS injection in a URL?

The issue is if you accept user input as part of the url you output, as in this example given by OWASP:

link

The attacker does not have to break out of the URL context, but out of the string, eg by injecting:

foo" onload="evilJS();" foo="bar

or to break out of the a tag as well:

">


Is null-byte injection possible in Java filenames? From the Area51 proposal

Accordingly to the following resources:

Null byte attacks are alive and well
Null Byte Injection
Java Null Byte injections

we can conclude that Null Byte injections are possible in Java.


How do worms spread over LAN? I've been researching LAN recently, and I came across a post talking about viruses spreading over LAN, and I was wondering, how is this possible? Would it not be a huge security issue to allow files to automatically be installed over LAN?

Here are some ways using which computer worms can spread over a LAN:

Exploiting vulnerabilities: The number one method is exploiting a vulnerability in the operating system or an installed software. The worm starts launching exploits from patient zero in your network against other computers hoping that they don't have the latest patches/updates installed. Using those exploits, the worm can execute shellcode on the target machine and get it to download and execute a version of the worm itself.
Weak passwords: The worm will usually try to launch dictionary attacks on other machines on the network in order to find the correct credentials and use them to certain commands on a, albeit patched, the target machine. On Windows, this is possible using the admin shares.
Insecure configurations: One prominent example is using openly-shared folders. The worm can simply copy itself into the shared folder on another machine using some attractive name/icon like CounterStrike-Source_Installer.exe on computers connected at a LAN party.
Email: As the other methods, this method isn't specific to LANs and it is actively used to infect corporate networks. The worm will read the address book on the infected machine and starts sending carefully-written emails trying to convince as many people to click on a link and install a software (Example: Impersonating the IT department and asking the employees to install a custom Flash Player update, which is in fact a version of the worm itself), or to download and execute some attachment, etc.


Is full disk encryption on a server in a secure data center pointless? I am having a debate with several people regarding how much protection full disk encryption provides.  dm-crypt is being used to encrypt data which is required by my company to be encrypted at rest.  The Linux servers hosting the data reside in a secure data center with very little risk of unauthorized physical access, let alone someone actually stealing the server.

My argument is that in this situation, that while complying with the letter of the law, they have done little to nothing to actually reduce risk associated with unencrypted data.  In effect, from a logical standpoint, they are in the exact same situation than if no encryption had been implemented at all.  I am curious though if this train of though is correct, thoughts?

To tailor the question more to my specific situation, regarding physical protection, the controls around that are typically very sound.  I am not saying risk is eliminated but it is considered to be low.  Same with disposal of the drives, the destruction controls operate pretty effectively and risk is considered low.  From a logical access standpoint the servers are not Internet facing, are behind a firewall, logical access is well controlled (but many have access), and they are not virtualized. Further, the servers operate 24x7, the only time they are rebooted is if it's needed after a change or during installation of a new one.

My concern is that in the event an insider goes rogue, or an unauthorized user exploits a logical security flaw, then the full data encryption does nothing to protect the data versus using some of the other field or file level encryption tools available.  Whereas the people I am debating argue that this is not the case.

Two generic things you apparently have missed:

In case of disk failure, having the data encrypted at rest solves the issue of having potentially sensitive data on a media you can't access any more. It makes disposing of faulty drives easier and cheaper (and it's one less problem)
Full disk encryption also makes it harder for an attacker to retrieve data from the "empty" space on the drives (which often contains trace of previously valid data)

And if you're using VMs:

Encrypting the partition makes you less dependent on the security of your hypervisor: if somehow the raw content of one of your drive "leaks" to another VM (which could happen if the drive space is reallocated to another VM and not zeroed out), that VM will be less likely to have access to the actual data (it would need to obtain the decryption key as well).


are chrome extensions in the Chrome store generally safe? Should I ever be worried about installing any chrome extension from the Chrome store?

A lot of the Chrome extensions I have, have the permission "Read and change all your data on the websites you visit" - now that sounds fairly open ended permission that you can do a lot of damage with that (read through my emails, go into my internet banking?).

Can I trust a chrome extension to not secretly do malicious activities in the background? If so, why should I be able to trust these extensions? Is the Chrome store curated by Google?

Can I trust a chrome extension to not secretly do malicious activities in the background? If so, why should I be able to trust these extensions? Is the Chrome store curated by Google?

You cannot fully trust the chrome store.
For examples of malicious behavior see Uncovering Malicious Browser Extensions in Chrome Web Store from 09/2014, Adware vendors buy Chrome Extensions to send ad- and malware-filled updates from 01/2014 or Can you trust your browser extensions? Exploring an ad-injecting chrome extension from 10/2014.

The idea is often the same: gain some initial trust by being a well behaved extension and later turn bad.


CSR generation origin? Platform: Windows 7 x64

Development:  .NET 4

Web Server:  HttpListener (IIS not installed, will not be installed :) )

Can Machine A generate a Certificate Signing Request for Machine B and have the cert given back by the CA (Machine C) installed on Machine B? Is there any magic that happens during CSR generation that ties it to Machine A? If Machine A CAN generate for Machine B, what is the minimum required information that would be needed to generate the CSR?

-Shane

You can generate the CSR wher ever you want. The thing is, the private key is created at the same time, and whichever server is using the signed certificate in the end also needs this private key. Usually you can export this private key on machine A and import it on machine B together with the (sigend) certificate.

The minimum information required for the CSR depends on the CA you are using.


Is there a way to know when the microphone is recording? (Windows 10) Is there an open source windows 10 trick (or a tweak/app) that would just turn ON/OFF the microphone or at least shows when it records? (For instance when it will record, it will show a red icon on the task-bar)

I find it surprising in windows 10 (which use Cortana) to don't be able to know when I'm recorded. I would like to turn the microphone OFF when I'm not using Cortana.

The same question has been asked about linux

Yes. Attach an opamp and a 3V LED to either of the two wires, and it will pulse when the mic is active. The LED is easy to embed in the casing with a little 3mm drill. Go to electrical engineering on stack exchange, and they will help you.

Edit: It will be a lot quicker to add one of these:

You can get by with wirewrapping, but it's not recommended for audio cables. A cheap soldering iron costs 3-5$.

Connect wire (either red+ or black-, it doesn't matter), to either pins 1 and 2 or pins 2 and 3.


Preventing XSS for REST API I have a spring REST API and a client project. Client projects' HTML page uses jquery ajax calls to fetch data from REST API using json or xml format. My question is to avoid XSS attacks on a web page, where should i perform encoding of user input data (i.e. untrusted data)? Currently i am encoding data into my REST Controller before returning the response. I am following OWASP XSS Prevention cheat sheet article. But since in my scenario, everything is ajax calls and data fetching from json and putting into html using jquery, not sure about where should user encoder to encode untrusted data. Is putting encoding in REST Controller is good option?

Thank you in advance.

If the REST API purely returns JSON (and never HTML) then do the HTML escaping client-side, in JavaScript.

Whether the client's HTML page uses JQuery templating, or builds up HTML with calls to functions like .html() neither of these by default have XSS protection. One approach is for the client code to explicitly call an escaping function on all untrusted input. However, an approach I prefer is to use a JQuery plugin that does automatic escaping. Here are two approaches for this:

Making JQuery templates safe against HTML injection
Safe version of jQuery’s .html()

People may criticise this approach, saying "you can't rely on client-side control for security". That criticism is based on misunderstanding; in this particular instance you can rely on it.

It's notable that AngularJS includes automatic escaping by default. If they wrote JQuery from scratch today, I expect JQuery would also include this.

One of the reasons not to do HTML escaping in the REST API is that you may have a non-HTML client consuming the API. In that case you definitely don't want HTML escaping to be applied.

It is important you return JSON using the correct Content-Type header (application/json) to avoid API misuse attacks.


Security of Shared Corporate Credit Cards We are a medium sized company. Recently, one of the representatives of the finance department raised a question about the use of credit cards to shop on-line among different departments in our company.

His concern relates to cases when a person from Department X requests to make a purchase from a site directly from his/her office computer. The reason for doing so is having direct access to some sensitive data needed right at the moment of purchase.

Currently, a finance representative walks up to the employee's office and  provides the CC number.

Obviously, the risk comes from the stored CC information under that session associated to the user profile in the on-line store. Several risk scenarios rises like this if the user accidentally makes more purchases with that CC information, if that information is leaked, or if the user account is compromised.

We have proposed solutions such as using pre-paid credit cards, Verified-by-Visa, or safetypay, which requires accepting purchases (Finance Dpt) by someone else after submitting a purchase order (Dpt. User who purchases). However, not all online stores accept these payment methods not even Verified-by-Visa.

Alternative solution is to make the purchaser sign a form where Dpt. X accepts all the responsibility derived from the use of this corporate credit card. Nevertheless, we think this measure lacks the prevention factor an information security strategy must embrace.

Any help?

Issue everyone with their own corporate card, so you can link each purchase to an individual.


Signature scheme using RSA and SHA512 What do you think about this signature scheme using RSA with 4096 bit keys?

Being R pseudorandom padding, fixed length (4096 - 512 bits):

RSApriv(R || SHA512(M))

I know that it's not as secure as RSASSA-PSS, but it looks better than RSASSA-PKCS1 to me (because of the random padding).

Am I missing anything important?

Thanks in advance.

If you want a simple yet secure signature scheme, take a look at Full-Domain-Hash (FDH).
Properly randomized padding (as in PSS) can strengthen the scheme against chosen-plaintext attacks. AFAIK the main effect is that it improves the tightness of the security proof a bit, which I consider a relatively small advantage.

But since the attacker can choose arbitrary values as padding, improperly randomized padding can also cause weaknesses. Yours allows the attacker control over most of the message.

Assuming you're using big-endian encoding, the message hash will land in the least significant bits in your scheme. The attacker has full control over all the other bits. This means the padding is clearly weaker than even PKCS#1v1.5 padding.

I expect practical forgeries, at least for small values of e.


Self-Executing Files I've always been curious about understanding how virus carry out their activities. For that reason, I've read a lot of books and articles about different types of viruses and the way they operate in a system. One thing that I have never found anywhere and I am really curious about is this:

For instance, let's say I have successfully developed a virus and I've made it penetrate into a system. At this moment, how that specific virus can start its job. Do they automatically launch themselves without the user being involved ? I mean an event requires to be triggered to fire an action if the virus is copied in the hard drive .What makes it run and carry out its evil duty without even being double clicked (started explicitly).

I found that in Linux it can be done by writing certain scripts but when it comes to Windows, you can't do this. An insight on the above would be appreciated.

(This is a very non-technical description of the whole process. Feel free to comment and ask)

The mechanism in practice is the same in all systems and it has much to do with why these things are called viruses instead of, say, bacteria.

A virus is not "alive" in that it lacks essential machinery. What it does is hijack the machinery of a more complex entity such as a cell, and make it do its bidding -- the virus may be no more than a hijacking mechanism with the "bidding" list as payload.

A computer virus is very similar to this simple structure.

How does the hijacking work?

A computer system has to have a boot sequence - first you do this, then you do that, further instructions are here, then... - and an action sequence (which is used to launch programs).

For example when you try to run an executable file, the system opens the file, finds out what it needs (and complains if it can't fulfill those needs - "missing library" for example), finds out how to place all the components packed in the .exe file in memory, determines where to do it, updates the components with information about each other so that they can communicate, unpacks the components and places them in the prepared places in memory, and finally releases a measure of control to the component marked "first".

The virus hijacks this process by (two examples):

locate the list of places where executable code is going to be activated
(MBR, boot sector, OS loader, OS stub, auto-executing scripts, boot processes, ...)
inject itself into this list, so that the system has one more thing to do when it starts, and that thing is breathing life into the virus chrysalis. This can be done by modifying the OS's list of things to do, or by placing itself in some convenient place such as the auto-run folder or Run registry branch in Windows. Anything placed there will be run at startup.
or it can replace one of the components, saving it somewhere else. When the system activates the component believing it to be legit, the virus does its thing, then it also retrieves the hibernated component and activates it as if it was the system. So in effect the sequence is again one step longer, but "officially", from outside, the number of steps is unchanged.

The virus may also write itself inside the diagnostic routines of the OS so that they report nothing out of the ordinary. This process may be run very close to the hardware, so that the infection is very difficult to detect.

To infect executables the virus does the same in a slightly different way. It can modify the internal "manifest" of the file so that the system will actually run the virus. The virus will then extract from its bloated "body" the carcass of the original process, and activate it in turn. The user will see the desired process running and not notice the slight delay in activation.

Disinfection requires knowledge of the virus so that the original file can be extracted from the infected object, and used to replace it altogether.

More sophisticated ways of hiding exist: many executable files have internal areas that are mostly zeroes, used as temporary storage of one kind or another. The virus hides there, and only does a slight modification to the file so that the "first component" to be activated isn't the original one but the empty area where the virus now resides. Being "inside" the file, the file size is now unchanged. The virus, upon receiving control, will move itself to some other place, again zeroing back the area (in memory) where it was hiding, and pass control to the old "first component", which will then notice nothing amiss.


Is it safe to rely on email address from 3rd party identity provider? Assuming that a 3rd party identity provider is reliable (eg; Facebook, Google, WindowsLive), is it safe to use email address (as provided by the service) to connect a user logging in with different providers to the same account?

For example, let's say I have a table that looks like this:

.-------------------------------------------------------------------.
| user_id | fullname | email        | facebook_ident | google_ident |
|---------+----------+--------------+----------------+--------------|
| 1       | John Doe | john@doe.com | 4362           | null         |
'-------------------------------------------------------------------'

If a user logs in via Google using email "john@doe.com", can I reliably connect him with user_id 1 (eg; set google_ident = "new_ident" and log him in as such)?

A few scenarios of concern:

If somehow the provider stops verifying the user's email address, someone can register on the service with an email he doesn't own and hijack the respective user on my system.
If, from my side, the user changes the email to one he doesn't own, he will be "passing on" his account to a user that happens to log in with that email later on (and hijack his account as well).

A possible solution I can see:

Disallow users to create accounts when their email address is already in use
Allow connecting of accounts only when user is already logged in

You're right that relying on a third party for your system's authentication can have certain drawbacks.

It's hard to grasp how you could consider letting a stranger (non authenticated user) link an existing account to another provider.  That would certainly represent a huge flaw in your design.

Normally, when using third party authentication, you allow a user to create an account on your site through the third party identifier and also log in with that same method.  You need to have that user already identified for any change they make to their account, especially when it comes to authentication details.

While it's not bad practice to link more than one provider to an account, it does lessen its security as that single account can become vulnerable to flaws of more than one system.


Why is the password hashes in my database the exact same for all my users? The hash is 1a469f2c34699d2b4ac3343fe6020a, all of my users passwords have this password hash when i looked in the database. So if I would try to crack a users password how am I supposed to do that if they all have the same hash? The hashtype is MD5. And why are the hashes the exact same for every users password?

The short answer is, you obviously have a (critical) bug in your hashing code. As it stands, anybody can probably sign in as any user at all, because for some reason your password hash function always produces the same output.

There's a few different ways this bug could come about, none of which are inherently obvious. One thing to definitely consider, though: are you actually including the password in the data you feed to the hash function, or are you terminating the hash without adding the password?

Another risk is that the bug is actually in your database code, and when you're creating / updating a user's password hash, you're accidentally setting it for all users, rather than just the specific one being created/updated. This is highly exploitable: I create my own account, and then use my password to log into an arbitrary user's account, because their hash got changed to mine.

OK, enough hypothesizing. The actually important stuff here is that, frankly, you should not be writing your own authentication system. Even leaving aside a critical bug that really, really should never happen - you should have found this during development or unit tests, if nothing else - your system is just not secure.

You shouldn't be using MD5 for anything, it's got known weaknesses and is considered cryptographically broken. You should be using the SHA2 family of hash functions for anything that needs a fast hash; even SHA1 is considered deprecated for new code.
You should never use a fast hash for storing passwords. Passwords should be hashed using a deliberately slow and expensive hash function, so that if somebody dumps your password database, it's hard to brute-force the password hashes it contains because each round of the brute-forcing takes a while.

Using a single-round fast hash, commodity hardware (like high-end graphics cards) can compute billions of hashes per second, enabling absurdly fast password-cracking. Instead, use functions that are intended for key generation or password storage.
PBKDF2 is the most common, but is also the oldest and least-amount better than a single fast hash. Bcrypt is better, but against modern hardware it's not really very good anymore. Scrypt, with the right parameters, is the generally-accepted modern option. There also exists Argon2, a new algorithm designed specifically for password hashing, and the winner of a three-year competition to determine the best such algorithm, if you want to be cutting-edge.

You don't mention per-user salts; are you using them? Salting passwords is absolutely essential, otherwise an attacker can just generate a rainbow table for whatever hashing scheme you use. Per-user salts break this attack, and also mean that (under normal situations) even if two users choose the same password, you can't tell that they did just by looking at the database; their hashes are different. All the good password hashing schemes take a salt. Salts should be randomly generated and are usually at least 16 bytes (128 bits) long.

At this point, I really have to say: you should use an authentication system written by somebody who is familiar with such systems, and who has a well-tested version ready to use. Don't try to write such security-critical features until you understand the area better.


If Apache is configured to parse PHP can users see PHP source code? If Apache is configured to parse PHP and not allow to index files, are there other ways users can see PHP source code, either with or without intention?

If Apache is properly configured with the php module loaded and correct mime types, you should expect to not have any code disclosed to the client.

Example:

AddModule mod_php.c
LoadModule php_module         modules/mod_php.so
LoadModule php5_module        modules/libphp5.so

AddType application/x-httpd-php .php

There don't seem to be any attacks against mime types in apache that would break this behavior that I know of. You should be more worried about poor coding practices, and disclosing the source code through other means such as file inclusion attack.

PHP does have a .phps extension that beautifies source code for sharing. If you use these files, make sure you strip them of any usernames and passwords before sharing them. It might be possible for a file to be incorrectly named .phps insteaf of .php -- unlikely, but possible.


Trying to get control of spam? Hopefully this question is deemed acceptable for this area of stackexchange. if not let me know what other site to use.

Anyways i'm seeking advice on how you try to eliminate spam in your daily lives. What i've done up to this point is just a total pain and i'm about to give up. I own my own domain. I essential have group email addresses. For example i have one email address for orders, one for forums, one for things that require my email that i never want to hear from, ect... Why is this such a pain? Well i use office 365 and you have to pay for each email address (so i only have 1). You can create forward email addresses so forward1@example.com will get redirected to mymainemail@example.com but you can email from the forwarded addresses. So i can't send an email from forward1@example.com which has caused issues.

Also say if you used forward1@example.com for all your orders and you have 50 sites you order from....not so easy to change is it? I will never be able to eliminate all but one account because you need say a google account if you use their services and a live.com account if you microsoft service but at least it would greatly diminish the headache i have now? Would you just forget about trying to use multiple email addresses and rely on strong spam protection? To be honest with you no one has my main email address...so at this point what good is it :).

We know no matter how careful you are eventually spam bots will get ahold of your address somehow (in someone elses address book or because of weak security on a site).

I use a different mail for every service, like facebook@mydomain.com, google@mydomain.com etc. This way I can see who sells my data or gets hacked (poor adobe@mydomain.com; )). Also I don't have to change 50 profiles after one incident but only one.

To adress your problem with Office360: I made a catch-all adress on my domain, where all mails arrive, so I only have to get mails from one inbox. If I see too many spam from one adress I simply block it.

The bigger problem is sending mails. Some Programms offer to enter any sender-address you like, but I know Outlook doesn't. Here I personally use a selfhosted webmailer where I can send from what address I like. It may not be the simplest solution but it works great for me.

For some important comunication it is also possible to create a temporary account while it lasts and delete it afterwards. I still get the mails through my catch-all address but have only one to manage.

I use this system for many years now and I have to say I am very satisfied with it. Not only I get nearly no spam but I also like the fact that I can identify which services I can trust and which not.


nmap OS scan showing DD-WRT when I'm not running it? This weekend, I set up pfSense on a spare box that I had sitting in the garage. It seems cool and powerful, but I haven't messed with it much yet.

Was doing some basic nmap scanning from work against my home public IP, and the nmap scan is apparently saying I'm running DD-WRT? My only other router (wireless) is sitting behind the pfSense box and it is running stock firmware, not DD-WRT. Can anyone help to explain this output? Perhaps it's just an erroneous guess as the output suggests it may not be accurate? Thank you.

root@kali:~# nmap -O my public IP

Starting Nmap 6.47 ( http://nmap.org ) at 2015-11-02 11:03 EST
Nmap scan report for my public IP
Host is up (0.015s latency).
Not shown: 998 filtered ports
PORT     STATE  SERVICE
6668/tcp closed irc
6669/tcp closed irc
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 2.4.X|3.X
OS CPE: cpe:/o:linux:linux_kernel:2.4 cpe:/o:linux:linux_kernel:3
OS details: DD-WRT v24-sp2 (Linux 2.4.37), Linux 3.2

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 50.44 seconds

The answer is in your question :

Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port

Nmap literally guesses which OS is on the machine. Didn't work out this time.


What is the safest and most convenient way to transfer data from my computer to "unknown" USB devices? I recently attended a friends wedding.

As a gift to the couple I filmed lots of things and edited the clips into a montage of the big day.

Thankfully they loved it and I have had requests from a number of people who would also like a copy.

Due to file size and poor internet speeds it is not really feasible to share online and I also don't want to post it online.

I have considered physical media but don't want the hassle/costs involved.

I have decided that I will simply place copies onto anyone who provides me with a USB stick/ hard drive big enough. This seems to work well for all parties involved.

Maybe I am being a little paranoid now but I don't know all the people that have asked to have a copy, and I am a little unsure of just plugging in random USB drives into my machine. I highly highly doubt that anyone has any malicious intent but even so I guess a virus could be passed on through an infected drive unintentionally etc.

Is there a fool-proof (and preferably easy) way to make sure that I can only write files to the USB and that any USB stick/hard drive will not have access to my PC and won't be able to do anything bad like infect my computer or access my files etc.?

Windows 10 is my OS.

Unfortunately it is very difficult to plug in unknown USB devices to exchange data in a manner that is guaranteed to be safe; there's a reason secure facilities often completely disable USB ports. In some cases a USB device could even be designed to cause physical damage and there are very few devices that have circuitry designed to protect against this type of attack.

The only method I can think of that could reasonably "guarantee" safety would be to set up a sacrificial computer, probably something cheap like a Raspberry Pi, and transfer your files there. Then disconnect the sacrificial machine from the network and use it to transfer the files to the potentially unsafe drives. When you're done, wipe and reinstall the sacrificial machine. I'm guessing this is probably more effort than you're willing to expend, so if you aren't willing to accept the risks, I would suggest exploring alternative methods of file transfer.


Privacy issue on corporate device On my corporate phone which has my Exchange account. Browsing incognito on my home WiFi. Can my employer find out what I am browsing on an incognito page? I am using am iPhone.

If the company has installed remote admin or remote monitoring software on the phone, then yes.

In general, if someone else gives you a phone, you cannot expect much control over the device.

But this is really a question that you need to discuss with your company's IT department. Most countries require that if they are monitoring you, then they need to inform you, or at least tell you if you ask.


Is OSX or Mac hardware used in the InfoSec world? What resources are available? Possible Duplicate:
  Mac OS X from an IT Security Practitioners' Perspective?

I'm new to the OSX world (formerly Windows background) and am interested in understanding what is or isn't possible with OSX natively or with a virtual host.

Is OSX or Mac hardware common in the security world?
Would it be easier for me to run pen tests from a dedicated VM running a different OS?

I purchased the Wifi Pineapple and notice that there are no instructions for OSX and am curious if this is a relevant hardware or software platform to initiate pen tests from.

The penetration testers over at Pauldotcom are perhaps the most famous security practitioners that openly talk about using Macs for their penetration test. From my personal experience, I've seen a number of digital forensic security practitioners who prefer using Macs.

As far as running your penetration tests, its likely easier to run your penetration test from a VM running a Linux distribution such as Backtrack 5 and utilizing Metasploit/Penetration tool inside the distribution. Whether you do this from a Mac/PC or Linux platform should make no difference inside the VM.

Here are some additional links that I found that may contain useful information on using Macs for Penetration Test:

https://web.archive.org/web/20130306081803/http://www.techrepublic.com/downloads/investigate-mac-os-x-as-a-platform-for-penetration-testing/293669

http://www.pen-tests.com/penetration-testing-linux-vs-windows.html

Goodluck!


Difference between Lynis and Nessus and yet another hardening tool I am writing an open source python tool aimed at inventoring/auditing and hardening of a system. When I started off with the project, I did some research around it and figured out that there were not many tools (at least open source) that did that (I would later come to realize that apparently I was wrong)

As of now I have written the core of the system which has the following features:

It is going to be open source
It is plugin based. Plugins are again written in python
It is not going to install any agents/binaries on the remote machine/s
It is going to provide visualization on top of the data collected and analysis done
It is going to generate Ansible cookbooks to facilitate admins to use it directly to fix the system (if they wanted to use it at all that is)
Capabilities of the system depend on the plugins's capabilities
As of now the tool is limited to Linux alone, but there are plans to expand it to other platforms as well.

I already knew about Lynis, before I started writing the tool and it looked like Lynis missed in a few small areas that I could improve on. Hence, I went ahead to write this tool.

Now after I have written most of the part of this tool, I get to realize that there is Nessus which already does something similar. And now I am rethinking if at all it makes sense to write this tool, is it really solving a problem or have I just wasted time reinventing the wheel (once again).

I however found this comparison of Lynis and Nessus, by the author of Lynis itself, and am not really convinced as to how is it different from what Nessus already does (not that I am a fan of Nessus or anything)

So here is what I actually want to know :
Does it really make sense to write another OS hardening tool like the one with the capabilities above ? Or would it actually make more sense to simply scrape the project now ??

Author of Lynis here. Nessus is vulnerability scanning, Lynis is system auditing with some overlap in vulnerability discovery.

I'm curious why you want to start a new project. So let me answer by sharing some background about the Lynis project: The project is almost 10 years old. It got a lot of iterations to improve the tool to where it is now. More importantly, it is still open source and receives regular updates. The amount of work that goes into an open source project can be overwhelming. Especially keeping it up-to-date, the questions your users will ask, the promotion needed, etc. etc. I'm the first to say "go write your own", but I learned along the way that the maintenance burden is a serious one to consider.

So let me rephrase the question above: why not become part of the ecosystem and contribute, create add-ons, join efforts?

If you like, I happily make time available to discuss (by email, chat, or even phone). The world needs quality (the best possible tools), not quantity (many average tools) :)


Storing Apache logs in docroot I have a client who hosts multiple sites in Apache. They're storing each site's access.log and error.log in the docroot under logs/, and they're publicly accessible via the web.

To me, this seems like bad practice, but I don't have any good arguments as why it's a bad thing. From a security standpoint, is it a bad thing for logs to be publicly accessible?

Yes it is. For one, the logs may contain personal information, such as IP addresses. They may also show what exactly the users viewed and when. More importantly, error logs may even contain sensitive information if things go wrong, such as passwords or more likely session tokens. Lastly, seeing exact errors may help attackers, who are trying to break the site. Knowing why exactly what they are doing is not working is a big help.


Why don't web interfaces on consumer routers trigger untrusted certificate warnings? Router manufacturers do not know what IP address their device will be assigned and therefore should not be able to register a TLS certificate for a router. However, some routers have HTTPS web-interfaces which do not trigger un-trusted certificate warnings when accessed.

How do router manufacturers achieve this?

The other answer is not completely right, hence I‘ll try and fix that.

There are two different types of web interfaces for routers:
The internal and the external web interface.

While the external should be disabled for many reasons, the internal one does not need https to be deployed: as you are accessing the router from your LAN (let‘s just assume, CRACK might be fixed some day and WiFi is considered secure again), a MITM can only operate locally, which is not a big threat in most consumer cases.

Yet, generally it would be desirable to have https on COTS routers. This poses significant problems. While the IP itself would not be a huge problem as the actual IP is only checked when accessing directly via IP (as the IP is taken to be the domain), there is another problem: most SOHO routers either have no DNS zone for the devices or they can be configured.

Even if all routers of one model were to be configured with a not-changeable local domain name like „routerxy.local“, .local is a domain no CA would ever create a certificate for. This is the point the other answers misses. It’s not the storage of the certificate and key that is the deal breaker (it is one as well though, but could be mitigated with an HSM), it is the local domain and how CAs work.

There would be a way to mitigate this problem as well:

Maker x can create routery.x.tld and obtain a certificate for that - and distribute that in the HSM of every box they ship. If this gets leaked (by a vulnerability in the HSM, for example - they are now in the hands of the potential attacker), you are in huge trouble all over again.

Additionally, most CAs might revoke the certificate when they see abuse like that (as the entity the certificate is for is not the one using it)

All in all: there are technical difficulties that hinder usability (we do not want certificate warnings on our COTS router) and there is little benefit from using TLS on a connection that is merely within the LAN.


Public key or Private key I've reading about asymmetric cryptography and I know that the concept is to keep the private key to yourself and distribute the public key. But recently I accessed a remote server using SSH with a .pem file.
The command I used to access was
ssh -i ./key/private_key.pem -l comp <ip_address>

I checked the manual page for ssh and it says

-i identity_file
 Selects a file from which the identity (private key) for
 public key authentication is read.

I wonder why I was given a file with private key, how was I authenticated, and what did the server have?

With -i you supply the private key to the server. The SSH daemon must be configured to accept public keys as an authentication method. When it is (and on most Linux distros this is the case for OpenSSH) then the server reads public keys from .ssh/authorized_keys. This file can contain multiple public keys from different users/hosts. Each public key occupies a single line in the file.

When your SSH client connects to the SSH daemon with a private key (default id_rsa in .ssh/), the private key is send after the ServerHello. The public key can verify the private key and from that point on the SSH connection is established.


Apparently PayPal-affiliated site with very suspect security History

I got an email this afternoon to my gmail from "paypal@e.paypal.com" with mailed-by: na.e.paypal.com and signed-by: e.paypal.com. Gmail did not report it as spam/phishing/suspicious and it went straight to my inbox, so the MX records must check out.
The email effectively linked to this url.
The URL, when clicked, presents an HTTPS encrypted website bearing PayPal Inc's Class 3 EV certificate from Verisign, which is not easy to obtain.

By all accounts, it appears that the site is a legitimate PayPal property.
But then things start getting extremely suspect:

If you click "Continue" on that page, with or without entering any text in the email address field, it works -- it takes you to the "logged-in" site. Indeed, the "Log in" button at the top of the page turns to a "Log out" button. It's basically a smokescreen.
Then, immediately, you are greeted with a pane that displays cross-domain advertisements from other domains to try and get you to buy stuff. What in the world is the point of this website other than to display (possibly malicious / suspicious) third-party ads to get PayPal more money?
This makes absolutely no sense, and it really shakes my trust in PayPal as a company if they're willing to put their Class 3 EV cert on a site with this level of stupid. Also, the "AVAILABLE BY INVITATION ONLY" is completely a lie; you can go there on any computer in the entire world and click "Continue", and you're "in", for all that it's worth (which is, basically, nothing).
My concern is more that they implemented a website with such nonsense security; only sent out "invites" to certain users; and then had the gall to put their EV cert on it as if they endorse this hogwash. Why would a site go through the trouble of having an email "login" screen when what they want to do is to just display advertisements to anyone who's foolish enough to visit the site at all?

I have been doing further research, the special site has "PayPal, Inc[US]" certificate and the paypal original site has "PayPal, Inc.[US]" certificate (note the dot after Inc).

The certificates contain this (relevant) information:

CN = www.paypal-special.com
OU = Partner Support
O = PayPal, Inc
STREET = 2211 N 1st St
L = San Jose
S = California
PostalCode = 95131-2021
C = US
SERIALNUMBER = 3014267
2.5.4.15 = Private Organization
1.3.6.1.4.1.311.60.2.1.2 = Delaware
1.3.6.1.4.1.311.60.2.1.3 = US

CN = www.paypal.com
OU = PayPal Production
O = PayPal, Inc.
STREET = 2211 N 1st St
L = San Jose
S = California
PostalCode = 95131-2021
C = US
SERIALNUMBER = 3014267
2.5.4.15 = Private Organization
1.3.6.1.4.1.311.60.2.1.2 = Delaware
1.3.6.1.4.1.311.60.2.1.3 = US

There is something strange here as well, both certificates have the same serial number.

But, this certificate is quite expensive for two years (3 000 dollars) so I suppose the page is legit but a bit abandoned and they have not put enough effort in it.

Also, about the domain information, we can find the following data (which is consistant with the certificate information):

Domain Name: paypal-special.com
Registry Domain ID:
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2013-12-23T04:01:12-0800
Creation Date: 2013-10-23T16:12:23-0700
Registrar Registration Expiration Date: 2015-10-23T16:12:24-0700
Registrar: MarkMonitor, Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email:
Registrar Abuse Contact Phone: +1.2083895740
Domain Status: clientUpdateProhibited
Domain Status: clientTransferProhibited
Domain Status: clientDeleteProhibited
Registry Registrant ID:
Registrant Name: Host Master
Registrant Organization: PayPal Inc.
Registrant Street: 2065 Hamilton Avenue,
Registrant City: San Jose
Registrant State/Province: CA
Registrant Postal Code: 95125
Registrant Country: US
Registrant Phone: +1.4083767400
Registrant Phone Ext:
Registrant Fax:
Registrant Fax Ext:
Registrant Email:
Registry Admin ID:
Admin Name: Domain Administrator
Admin Organization: eBay Inc.
Admin Street: 2145 Hamilton Avenue
Admin City: San Jose
Admin State/Province: CA
Admin Postal Code: 95125
Admin Country: US
Admin Phone: +1.4083767400
Admin Phone Ext:
Admin Fax: +1.4083767514
Admin Fax Ext:
Admin Email:
Registry Tech ID:
Tech Name: Host Master
Tech Organization: PayPal Inc.
Tech Street: 2211 North First Street
Tech City: San Jose
Tech State/Province: CA
Tech Postal Code: 95131
Tech Country: US
Tech Phone: +1.4083767400
Tech Phone Ext:
Tech Fax:
Tech Fax Ext:
Tech Email:


Metasploit Ruby Scripting: Problem with framework.db.creds I am trying to access the credentials I have gathered so far with Metasploit in a Ruby-Resource script. Unfortunately I get the following error when I try to access framework.db.creds.

>> framework.db.creds.each
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  missing    FROM-clause entry for table "hosts"
LINE 1: SELECT "creds".* FROM "creds" WHERE (hosts.workspace_id = 2)

When I look into the creds table, I see that it is not populated. Instead, I see that credentials are stored in metasploit_credential_* tables. The creds method seems to be supported, though...

>> framework.db.methods.each do |m|
?> next if ( m !~ /creds/ )
>> print_line("#{m}")
>> end

creds

Am I doing something wrong or is this a (known) issue with Metasploit?
I discovered this problem when trying to run the supplied auto_pass_the_hash.rc script.

I'm running the following version of Metasploit

msf > version
Framework: 4.12.13-dev-202969fae9c0a27bff5c1a82cbe4badb7438036d
Console  : 4.12.13-dev-202969fae9c0a27bff5c1a82cbe4badb7438036d

Patch is available at https://github.com/rapid7/metasploit-framework/pull/7104. If you are using the Github repo, pull the PR in and test. Otherwise, you will have to wait till the patch is included in the Kali update or MSF Pro/Community versions.


If a service that I registered with FB/Twitter/G+ is hacked, what mischief can be done with the oauth token? Case in point, TrueCaller. I had logged into TC using a proxy twitter account. I am assuming that as part of the authentication process, an access_token must have been saved by TC.

If the hackers have this token, what can they be able to do with it?
Assuming that the hackers have gotten a hold of my database, what can I as a developer do, to minimise the effect of the leak? What are the good practices for such login?

Thank you.

1 . If the hackers have this token, what can they be able to do with it?

That depends on the individual "social network", but such tokens are mostly configured to expire/invalidate after a certain period of time. Also, the networks you mentioned all have multiple security implementations running to limit such attack vectors by — among other things — linking the token to the IP. Ask yourself how unlikely it is that an attacker will be able to fetch multiple characteristics simultaneously…  I can't say it'll not happen, as Murphy's law would most certainly prove me wrong. ;)

  2 . Assuming that the hackers have gotten a hold of my database, what can I as a developer do, to minimise the effect of the leak? What are the good practices for such login?

Follow the procedures you would follow in relation to every information security incident — apply the 6 Phases of Incident Management:

Preparation
Identification
Containment
Eradication
Recovery
Training

To dive deeper into "incident management", you might want to start out by checking the following infos:

SANS: An Incident Handling Process for Small and Medium
Businesses (PDF)
SANS: FORENSICS PLAN GUIDE (PDF)


Why can't iptables drop arp requests I was trying to hide my laptop from my phone's network scan app. The app is using arp requests to find devices on the network. I tried everything on iptables. It doesn't work, even if i set all the policies drop. Fortunately arptables can drop the requests. But why iptables can't do that ?

ARP and TCP/IP are different layers in the networking technology stack. If you have read about the OSI model, that applies here.

ARP is a protocol at layer 2 dealing with connecting the host to the local network.

TCP/IP are protocols dealing with connecting networks together.

iptables deals (mostly) with TCP/IP and higher layers. arptables deals with the ARP layer.


Transferring passwords to outside counsel As part of a new eDiscovery effort, we send large amounts of data on encrypted hardware to third parties (outside counsel) that are not very technically proficient (so no key exchange via PGP desktop).  Our compliance policy states no passwords in emails but IT Sec team has no great workaround other than voice communication.  What other ways can we communicate this password?  Is the fact that the email is completely separated from the hardware good enough?

Edited with more info

A little more information after doing some additional digging.  There are some third-party tools that appear to be made for this kind of issue: self-destructing password notes, pay utilities, etc... Joel Spolsky mentions using file-sharing sites.  That seems like a good compromise, put the password in a file and share the file with the specific email of the person you are sending the drive to.  Any further thoughts on these approaches?

As a matter of policy, I wouldn't use any form of communication that's by default recorded because you never have control over what happens to it and who might have access to it in the future.  That rules out email.  As you mentioned, the public key methods are out too, since the lawyer isn't technically savy enough.

Data normally is unlikely to be stolen in transit, but far more likely to be stolen at rest.  So while email, and a voice call are both unencrypyed, the voice call is far more secure since they normally aren't recorded.  Though these days it's possible that even a voice call to a lawyer might be recorded.

You'll have to set your own level of paranoia, but it sound like you're not the NSA, so I'd say if you and the lawyer both know each other and can recognize each others voice, that's going to be "secure enough" to thwart evil doers.  You'd still be vulnerable to government snooping of course.  Check with your lawyer if exchanging a password is protected by attorney/client privilege.


x-frame-options header doesn't prevent showing site in iframe For my site I see that  among response headers there is X-Frame-Options: SAMEORIGIN. Still I can preview my  site in  iframe of some different site, for instance here. But I expected not to. I assume that this is back-end work to add some  more setting that would prevent the site from rendering in iframe? I thought that if it returns the above header the security functionality preventing showing site in iframe is already in place. Isn't it?

UPDATE: It's my fault I didn't specify that this header is returned for each  xhr but there is no such  header for static resources (html, js, css, images). Might that be a reason?

UPDATE2: I've asked BE guys to provide the  header for static resources too. After implementation I'll share whether it helps or not.

I asked that the URL be posted so more eyes can examine the header.

If that can't be done, check the following by looking at the header as your browser sees it in the developer tools.

If this header is set more than once, it can cause the directive to fail because the browser will condense multiple instances of the same header into one so that it becomes:

X-Frame-Options: SAMEORIGIN,SAMEORIGIN

and this value is not one of the three allowed so the header will be ignored.

For example, if your web server sets it and then code in the application sets it again, it will happen.

source:
https://blog.qualys.com/securitylabs/2015/10/20/clickjacking-a-common-implementation-mistake-that-can-put-your-websites-in-danger


Response to script-kiddies "scanning" website for vulnerabilities? I have a website and I have email reports when 500 errors occur. Many of these errors occur because "hackers" are running scripts to look for common vulnerabilities or access to admin interfaces - attempting to get to pages such as /admin/config.php.

This has happened 3 times in the past week and I can see that one's IP is in Russia and the other is in China. I understand they may be behind 7 proxies but interesting nevertheless.

Is this common? How should we react to this? I'm considered blocking 'Python-urllib' user agent but nifty users can simply include a custom user agent in their header so that's not a comprehensive measure.

Make sure you keep things patched and monitor the situation for any successful breaches.  Consider changing passwords more often than usual as a precaution, but this is pretty typical behavior.  On larger sites, it's basically constantly happening.  When I was running the server for a fan run Nintendo news site that was reasonably popular, we probably had several thousand hits a day that were trying to find issues.  Visibility makes a target more attractive and a lot of the vulnerability searching is automated.


PUT vs. POST for password update I am writing a User Management system that has to include a change of password utility. We don't front end hash passwords (hopefully we will soon). As a result passwords are passed over https in the clear whenever a user is edited or his password is changed. Is there any difference in using "PUT" vs. "POST" requests in this use case. I would typically use "PUT" because it is a replacement/edit but I know for authentication the standard is "POST"

The PUT HTTP verb is supposed to be idempotent, a smart word meaning that sending twice the request should not have any further effect. The idea is that a "PUT" command is the opposite of "GET": the data contents sent with a "PUT" are supposed to be stored at the specified URL, and may conceptually be obtained back from that same URL with a "GET". In that respect, PUT and GET mimic the expected behaviour of FTP.

On the other hand, a "POST" is the generic verb for API-like calls: orders sent to a server for immediate execution. Such API calls are not idempotent. A "change password" call should probably be envisioned as an API call, not a file transfer. Therefore, you should use POST instead of PUT.

See for instance this blog post for further discussion about PUT vs POST.

From a security point of view, there is no real difference between PUT and POST: everything goes through the SSL, and it is mostly a matter of convention between client and server. As long as the client and server understand each other, then the security offered by both requests is the same.

The theoretical difference is that a client might take upon itself to issue a PUT call again in case of network failure, while it would not for a POST. Generally, you prefer the POST semantics, and keep PUT only for bulk file transfer where such reemission would be a nice feature, and not a problem.


Decrypt iPhone DD Image I wanted to recover with foremost or scapel the a girlfriends iPhone 4, because she had deleted all the videos of her daughter.

What I have got:

A backup of the iPhone with iTunes without password.
DD image of rdisks0s1 16 GB mountable on Linx. Everything is there.
A copy of all files with WinSCP uncrypted. System.kb ... phone was jailbreaked and DFU mode and with an early verison of the Geckotool.
deviceinfos (EMF,dataVolumeUID,key835,key89A,key89A,...)
Keychain decrypted

What I havent got:

I cant bring the thinks togehter and I gave back the phone, because she needed it.
When I try to run iphone_Dataprotection EMF_decrypt it says "Keybag locked". Is there a way to unlock the keybag without the IPhone? In the tool I used was not the command to bruteforece. Just the possibiltiy to mount the filesystem to mnt1 & mnt2 and device infos.

Is here somebody who can show me a way to decrypt the image?

This is actually harder than you might think. An iPhone's automatic data protection encrypts each file with a random key, and stores a copy of the key encrypted with the appropriate class key (from the keybag, where it is encrypted with the phone's UID key and the user's passcode) in the file header in the filesystem.

Upon deleting a file, the file header in the filesystem is cleared, so the encrypted key is lost, effectively accomplishing a cryptographic erasure of that one file. Therefore, something like Photorec on the disk image will get you nothing. Even recovery of the class keys is useless, because the wrapped file encryption key has been lost.

Of course, to gain full NSA-resistant security when doing cryptographic erasure on flash, you have to store the key on a section of the flash that doesn't have overprovisioning or copy-on-write or any of the other handy flash translation layer features that might leak old data. The key for the whole filesystem is stored in just such a special area, called Effacable Storage, but the wrapped per-file keys are not, so perhaps desoldering the flash and dumping it chip by chip might let you recover the wrapped keys. Of course, you'd still need the iPhone's UID key to decrypt the transparently-encrypted filesystem header that was decrypted for free before you desoldered the chips...

At some point here you bash your brains out on the wall and die.

(A corollary to all this is that wiping the free space on an iPhone is pointless, because it's already been cryptographically erased.)


How to connect to a wifi network that shuts down connections Our school's wifi shuts down after 12 am, and although we are still connected to the network, our connections are closed, and the computer says "no internet".

However, we can somehow manage to stay connected to the internet even after 12 am if we use a VPN program, but after disconnecting, we cannot connect to the network again even using VPN

How does this shutdown system work and how can I connect to the internet even after it closes all connections?

How does this shutdown system work?

Based on your description it seems it does this on a stateful firewall by preventing new connections. VPN connections are already established connections, and everything goes inside the tunnel. That's why they continue to work.

  How can I connect to the internet even after it closes all connections?

Buy an own Internet subscription without this limitation.


Why are unsigned Java applications blocked? Anyone can purchase a code signing certificate. They are cheap and do not involve much validation. Yet Oracle must have determined that disabling execution of unsigned applications increases security.

Does it really, and what is the mechanism that leads to increased security? (other than the fact that any mechanism that blocks a random subset of applications will invariably block some malware too by pure chance)

A few reasons:

Buying a certificate would leave a paper trail, allowing malware to be more easily backtraced to the person that paid for the certificate.
It increases the barrier to entry for creating malicious Java applets, because of the cost.
I believe CAs (e.g. VeriSign) require you to provide evidence that you are a legitimate provider of software.

That being said, you're touching on a major problem with PKI: you have to rely on CAs being infallible and trustworthy.


What scripts does nmap Option -A use? Can anyone answer which scripts are used when the -A flag is used?

The answers I've found all point to the generic -A: Enables OS detection and Version detection, Script scanning and Traceroute. help info which doesn't answer which scripts are used.

Is it equivalent to having --script="(default and safe)" or something else?

Yes, it is identical.
You can verify this by looking at nmap.cc, which parses the arguments. The handler for -A sets delayed_options.advanced to true, which in turn sets o.script to true. This is identical to the -sC flag, which also sets o.script to true.
As for which scripts are run, this depends on the nmap version. By default, it runs scripts that nmap considers "safe"


What is the correct course of action when a hash function used to hash passwords is compromised? This is a hypothetical situation, not one I am currently in.

Suppose I'm using some hash function, call it H1, which is considered relatively safe currently to store passwords. I'm also using a salt. If tomorrow the hash function will be considered compromised (or something to that effect), as happened with SHA1, what should I do to re-secure the passwords?

Naively, I would like to reconstruct the passwords hashed with H1 and rehash them with a relatively safe other hash function, H2. But, of course, this is impossible since the whole point was to not be able to reconstruct the passwords. I was thinking about 2 possible courses of action:

Hash with H2 the H1-hashes. Now in order to authenticate the user I would have to hash with H1 and then H2 and compare. This basically treats the H1 hashes as plaintext passwords albeit more annoying for the attacker. In this scenario, would one need another salt for H2 or can the one from H1 be reused?
Immediately revoke the stored passwords and email/text (or any 2nd authentication method) users a temporary password which has to be replaced with a new one upon the next login, the latter hashed with H2 and salted with a new salt.

Comparing them, it seems to me that 1 has the advantage of not involving humans and not relying on a 3rd party channel, although resetting passwords this way seems fairly common. It has the disadvantage of additional clutter and work required to authenticate.

Are one of the above 2 considered the correct course of action, or something else is?

Option 3 is to re-hash the passwords when the user logs in (and you thus briefly have access to the unhashed password), and accept the reduced security for users who have not logged in since before you made the change.


For a password, is it better having a number in the middle than at the beginning or the end? Sorry if this was asked before but I could not find an answer to my doubt.

While trying to decide a new password for a given website I came across a password strength checker website that (somehow) claims that having a number in the middle positions of a password is better than having it at the beginning or the end.

Out of curiosity I have checked other websites dedicated to checking password strength like this and this, but none of them seems to see a difference between, say 4abcD and abc4D, as the first one does.

While I do not really believe such sites can be regarded as scientifically accurate, I am wondering if there is something true in the "claim" that having a middle number makes a password stronger than having the number at the first or last position. Does it really increase the entropy of the password?

If you put it in the middle of a word or sequence, where it would otherwise have been at the end, such as abc4D compared with 4abcD, then you have increased the entropy of the password because there are fewer sequences or words that would be susceptible to a dictionary attack. However, that can't be said for correct4horse compared to correcthorse4, yet the former is still considered to be secure. For that particular scanner, the reason that putting the number in the middle is considered more secure is because it deducts marks based on the number of consecutive letters, so putting a number in the middle reduces the maximum number of consecutive letters. However, while there is some merit to that, having the number in the middle has another big advantage - most people put numbers at the end of their password, so when someone tries to crack a password, they are more likely to try different numbers at the end than they are in the middle.

No password strength calculator will ever give a true value for how strong your password is, because there are so many variables involved (things like names and dates commonly occur in passwords, which can't really be checked against by a random scanner), so don't just believe that p@ssw0rd is a good password just because it is considered twice as secure as correcthorsebatterystaple. The password strength checker you linked is good because it explains what features it's looking for, but it is missing a dictionary check, which limits its accuracy considerably.


What is the point of sending an email informing a possible break in to the same account? There are several email services, including Gmail that for some time now sends an email informing that someone logged in from a different device.

An attacker, logging into that account would also have access to the message and would be able to delete it. What's the point of it than? Of course if the attacker doesn't know it you may actually be warned, but this would be the exception. Am I missing something else?

These emails are sent out whenever someone logs into your Gmail account, which is useful for when you are viewing the Gmail at the same time, or have a push notification service(like on your cell phone for notifications, which most people do). This service is asynchronous and ALL logged in users will see the email, even if one user sends it to trash(it would require a refresh on all users to see the message has been deleted).

So a common workflow for this is you're checking your emails when you are notified(instantly in the web and instantly by notification) that someone has logged into your account on a new device(or attempted too). If this happens you now INSTANTLY know in a way the hacker can't prevent. This gives you a small windows of opportunity yourself to stop the hacker while your Oath token is still good and you can lock the account(or if a bit too slow, start a recovery ticket). In asynchronous applications like gmail, yahoo mail, outlook, and many other providers where a login looks... fish-e... this can give the user time to fix the problem.

Now this may sound like "Well why doesn't the hacker just change the login details then?" Sometimes this happens, but if ready for it a user should be able to start the damage mitigation process themselves, and/or seek help to minimize the damage that does happen.


How secure is this token url for subcontractors with no accounts? Imagine you are a cab company that subcontracts independent drivers to drive within certain cities and towns.

You send the subcontractor a link to a page that has fields for the subcontractor to enter and submit information (such as how much money they made on a job they were asked to do, or comments about the job). The subcontractor doesn't need credentials (an account with username and password) to access this link. They just need the link, which is specifically meant for them, and which has a query string parameter that is a randomly generated access token. The subcontractor entering and submitting information from the page led to by the link sends data to the company's database.

This access token at the end of the URL is meant to keep the page secure and accessible only by the subcontractor. The access token is also time based. The subcontractor has 24hrs to enter the information from that link.

What is your opinion? How secure is this? This reminds me of the password reset links that websites send out. What if instead of 24hrs the link lasted for 1 month?

There are several scenarios you have to think about. If you are sending the URL over HTTP you (and your customers) are vulnerable to man-in-the-middle attack (the attacker will have access to the information sent to you by the subcontractors) and even if you are sending it over SSL that will protect your URL only during the transit, and if you are rely on emails to send it then SSL won't protect you from the insecurities of the email that may go through lot of servers before reaching your customer; and before all, it is a weak method to do so in that it is not supported by the merest authentication mechanisms (such as sessions).

Also the fact you need to send the URL subcontractor for each time you require his information, with its validity for 24 hours, expose you to more threats as it enhances the length of the  attack surface. And if the URL is cached by the browser and a subcontractor may use it more than once (you did not specify this through your question) then even SSL is useless for this particular case.

There are other considerations to think about too: what about  any internal routing, server logging?

For your last question:

  What if instead of 24hrs the link lasted for 1 month?

Again, if you enhance the time validity of the URL you are enhancing in the same time the surface attack as the subcontractor email (or the system with which he receives your URL) may be compromised by time.


Per Vendor/Publisher Device Unique Identifier, How is it and how much secure? iOS and WP8 support Unique Identifier per Vendor or Publisher according to this and that.
Android unfortunately does not support that feature.

Is there anybody knows the mechanics of that mechanism?

Has Apple/Microsoft revealed the identifier generator algorithm to the public?

Assume there are two apps (a1 and a2) from different vendors. If the app a1 gets its unique identifier by calling the API (for ex. [UIDevice identifierForVendor]) then on a jailbroken device, is it possible for the app a2 to know what the unique identifier for a1 is?

It sounds like the mentioned OS(s) store the Unique Identifier somewhere on the device and therefore it is vulnerable on jail-broken devices.

For instance, on a jail-broken device, a2 may search a1 private directory and find the location where device_unique_identifier for a1 persisted and get it. Is it possible?

I should tell you that I have read the documentation and run enough search. So please do not refer me to the original documentation and instead provide me with technical details if possible.

On jailbroken devices this is definitely possible. The simplest way (and not involving any reverse engineering) would be for application a2 simply spoof a1's BundleID.

As for the generation algorithm, I believe that on iOS that identifier is simply a random NSUUID that is generated when first app from given vendor is installed (and removed when last app from this vendor is uninstalled).

Cannot tell anything about WP though.


POS still PCI compliant after Single Sign-on? I have a Point of Sale System that's a web application. I also have a separate reporting system that's a web application and a separate inventory system that's a web application. It's necessary to use all 3 to run the business. I want to have single sign-on to make life easier for the users. Would adding single sign-on, via CAS, invalidate the PCI compliance of the POS web application?

Assumptions:

Your authentication / SSO solution is completely in-house.
Your POS application is the only covered application at this time.

In this case, your central authentication server would fall into the covered scope and would need to meet security and logging requirements. That other systems rely on this does not make them in-scope.


ARM TrustZone with Normal and Secure World I am new to Security testing and I am working on a 64-bit ARM server.
We are using ARM TrustZone technology.

Is it possible for me to check if I am in the Secure world or the Normal world?
How do I test the above scenario?

As a tester assuming I am in Normal world can you give some inputs to access application running in Secure world?

Check the NS bit in the SCR register (it's the same register on ARMv7 and ARMv8). You need to be in a privileged mode (i.e. EL1 and above). (Monitor mode (EL3) is secure regardless of the value of the NS bit but if you need to ask you aren't running code in monitor mode.)

It's a bit odd that you'd need to test that because typically the two worlds would be running different operating systems (if the secure world is used at all).

Whether a normal world application can communicate with a secure world application entirely depends on what operating systems are running in the normal world and in the secure world. The normal world operating system (EL1 NS) can issue an SMC instruction to switch to secure mode (via the monitor), which works roughly like SVC to make a system call from user to kernel.


Security of 3G network If I'm using a 3G modem on USB, is that secured or easily hackable? Is there some form of encryption built into it?

Is there some form of encryption built into it?

Yes, 3G has encryption. It usually is strong enough for attacks based on observation alone.

  is that secured or easily hackable?

Sigh. Could we move away from using words like "hackable" or "I've been hacked" in general? They're super non-descriptive.

If "hacking" means cracking the cipher used to encrypt the over-the-air data, no, that's pretty hard and I don't know whether that is done anywhere. That is, assuming that in a post-2010 world, operators have learned to use the right ciphers and periodically exchange keys.

If "hacking" means swindling and imposing as a legit base station to capture the traffic of a telephone, maybe with or without cooperation of the network operator: That's a lot easier.

If "hacking" includes your computer, to which you connect your modem: Well, you might have noticed that there's thousands of new malwares every month. There's certainly some security holes in your system. And that might be used to gain access to your data, regardless of encryption.


Hacked, is my IOS systems safe?Werid things? I hope this finds you well.  I wanted to thank you in advance for your time and patience with me, and my questions.

I was Hacked by friends of an X-boyfriend from HighSchool.  He was a Foriegn exchange student from Sweden.  We have had some personal communications in the past one spanning 5 years of both of our lives.  In short on FB Messanger-I shared photos' with him,from Christmas.  Someone started trying to figure out who I was, etc..Jan 16/16-Feb 12/16 It literally broke me emotionally. Five emotional years,photos,chats,e-mails are now gone. Along with other things. I was never ransomed.

My Question is that things are showing up on my IOS devices that should not be. Like porn photos, I have traced it, back to what I think is the source of the photos, they do not know I am aware.

I will receive text messages "alledged" from mms I thought once to be safe.
MMS-776-836 asking me to call a number and what number to use on a Microsoft Account Security Code.  The creepiest one was the one I received on Easter Sunday, 2016 alleging that it was MMS-332-651
Facebook Safety
Check: Are you
Affected by the
Explosion?

Reply SAFE if you're ok or
OUT if you aren't in the area.

I asked my cousins if they had received a text message like this?

We were literally sitting down for lunch, when I asked.

I had/have been trying to reach my X in Sweden, to see if he knew.  I had left him my X-BF from High School(ah we are both past our 30's) a message via insta-account/the day before Easter, then the strange text from MMS 322-651, popped in to my I-phone. I was receiving MMS codes from 837-401, from Microsoft security alledged. One day it answered a question I expected to be answered via a Yahoo.com account, It said my Yahoo verification code is XXXXX, etc.  The next message received us what my Yahoo ID was or currently is. I have had previous Yahoo accounts, I wanted those as they have e-mails I needed.  It said under my Yahoo id, we.garon,Iburkett34???? I literally have to say Whiskey Tango Foxtrott or WTF..It is not making sense. I had to write 3 papers over and about Sweden during the attacks..My material kept getting removed. I went from an A to an F in the course of a week and a half.  I had to drop the class.  I am aware the first server farm outside of the United States, is in Lulea, se.  I am aware of the issue with Hackers in the general area, i.e. sweden.

I have Google verification codes coming from what I thought was a legit source MMS 256-447, then one popped in not hyper linked.

Look it I left myself open to the Hack. He had all my information from previously and current. I am positive they do/did not think I had a clue as to what was happening.  I was on the computer when the largest Hack came in, I physically saw my name being removed from e-mails..I have been researching all of this. I am  aware of what C-code was used, what free/open source it was pulled from, etc. They left digital fingerprints every where.  Can you Help me? I am not stupid, however there is only so much I can do here in the U.S..I respectfully ask for your assistance with all of this Crazy, literally a heart breaking mess.  Someone on here may have helped these people out trust me I am not mad at anyone (I would really like to know why?)...I just need some clarification as to what is legit. What is not legit. Who(m) or What to trust.  Is my cell phone
I-6 clear or not? Is my I-pad clear or not?

Sincerely,
Amy M. Bearden

As helphul as it might be for you to figure out the motivation behind all of this, that is nothing we might help you with.

As far as the breach of your system goes:

A lot of online identities seem to be affected and compromised.
Your computer seems to be not you computer anymore.

There are several things we cannot help you with:

If you linked your iOS device with the computer that is no longer yours, a jailbreak and following up an infection might have happened.

Detecting wether that is the case or not is not easiliy possible remotely.
If you linked any cloud services to the identities that have been compromised with your iOS device, photos, documents, contacts,... might (dis)appear at any time.

Precious data should be backed up already. If that's not the case, there is little hope such data can be rescued.

There are several steps to take:

Check for infections across your network (router?)
Secure your network
Nuke all your infected devices from orbit
Regain control over all compromised identities by reaching out to their customer service
Use strong passwords, do not reuse passwords

Side note:

Note that this is not a forum but a Q&A site. Please read [ask] and do not use comments for extended discussions.


Can too much web searching be a danger to a security professional? As a junior security professional, I spend a lot of time goggling for things such as 'wpa dictionaries', 'vulnerabilities...' , 'how to crack ...','and so on.

I sometimes feel like I am calling for wrong attention (from ISP, google and/or agencies), regardless of my intention to increase my knowledge of what I am defending against and having fun on cracking my own home network.

Will googling draw too much draw the wrong attention? Wouldn't using proxies be too suspicious?

Google search data has been used to convict a murder.  But this is an extreme case.  I honestly don't think you have anything to worry about. If you are looking for a job in the US intelligence community then they might look at your email and search history before they higher you.  But in general there are bigger problems on the internet.

* Massive picture of Pedobear *(edit:  too large,  it was removed.)


Passing session id in query string to maintain state in third party iframe - good practice? I would like to allow the user to be "logged in" and maintain state / logged in status between pages within an iframe. The iframe content is ours, and will be hosted on various clients' websites.

Since the usual session cookie will most likely be blocked as a third party cookie I am trying to find a suitable way to do this.

I am considering always passing ?PHPSESSID=x in the query string for each relevant url as a workaround.

Is this considered bad practice and are there any risks involved?

I am considering always passing ?PHPSESSID=x in the query string for
  each relevant url as a workaround.

This is not the best practice, but if you decide to choose this method (because it is easy), you can make something like this:

<?php

    define("COOKIE_NAME", "PHPSESSID");
    define("DOMAIN", "example.com");

    function is_valid_cookie($cookie){
        //Test if the cookie is valid and does not have any malicious chars (";", etc)

        //...
        return true;

        //...
        return false;
    }

    function is_logged_in(){
        //Test if the user is logged in

        //...
        return true;

        //...
        return false;
    }

    function sanitize_url($url){
        //Sanitize URL
        //If you have PHP >= 4.4.2 or PHP >= 5.1.2, I believe you have nothing to worry here

        //...
        return $url;
    }

    function remove_querystring_var($url, $toRemove){
        //Removes $toRemove from query string of the $url
        $parsed = array();
        parse_str(substr($url, strpos($url, '?')+1), $parsed);
        $url = substr($url, 0, strpos($url, '?'));
        unset($parsed[$toRemove]);
        if(!empty($parsed)){
            $url .= '?' . http_build_query($parsed);
        }
        return $url;
    }

    if(isset($_GET[COOKIE_NAME])){
        if(is_valid_cookie($_GET[COOKIE_NAME])){
            setcookie(COOKIE_NAME, $_GET[COOKIE_NAME], time()+24*3600, "/", ".".DOMAIN, true, true);
            header("Location: ".sanitize_url(remove_querystring_var("https://".DOMAIN.$_SERVER["REQUEST_URI"], COOKIE_NAME)));
            exit(0);
        }
        else{
            header("Location: ".sanitize_url(remove_querystring_var("https://".DOMAIN.$_SERVER["REQUEST_URI"], COOKIE_NAME)));
            exit(0);
        }
    }
    else if(!is_logged_in()){
        echo "Invalid session!";
        exit(0);
    }

    //...
    echo "Welcome!";

?>

Example:

https://mail.google.com/mail/u/0/?auth=xxxxx&anything=yyyyy

Google will use and exclude the &auth variable, but will keep the &anything, because &auth have sensitive data for Google.


Which 12 month time frame is used for PCI merchant levels? We self certified as a level 3 vendor in March of 2016. Since then we had far more transactions and may be in level 2 turf (ugh).

My question is, which 12 month period does the PCI certification look at to determine merchant level? The 12 months directly preceding the audit? (in which case if you are borderline do you just have to guess what level you are leading up to the audit?) Or is it the 12 months before the last audit?

According to Mastercard US, to determine your merchant level, you look at the most recent 52-week period:

  Determine merchant level using Mastercard transaction volume from the most recent 52-week period

So if you're having a PCI audit, your merchant level is determined from that moment in time.

That being said, each card brand has their own definition and requirements for each level. Many of them are similar. You can see a good breakdown here, but you should check with each card brand for the most up-to-date info.

The best solution is to contact your merchant services provider (credit card processor), and they should be able to tell you what level you fall in for each card brand, and what your PCI validation requirements are.


Is Java secure for the desktop? The Java plugin for web browsers is known to have many security issues, at least in the past. Google Chrome is not even supporting it any more, describing it as decrepit technology, and Firefox having a little warning message near it.

But is the JRE secure with out the browser plugin? Are Java desktop, mobile and server applications as  vulnerable as the Java plugin?

Yes - Java desktop and server applications are basically secure.

When you run a desktop application - Skype, Picassa, whatever - you give that software full access to your computer. You have to trust the software.

In contrast, when you run a Java applet in your web browser, the applet runs in a restricted environment called a sandbox. The sandbox exists so you do not have to trust the Java applet.

Java has had a lot of vulnerabilities; almost all of them are "sandbox escapes". In other words, if you're running an old version of Java, a malicious applet can break out of the sandbox and take control of your computer.

Not many technologies support sandboxes. In fact, there are only three common technologies where people routinely run untrusted software: Java, JavaScript and Flash. All of these have had many sandbox escape vulnerabilities, which demonstrates the difficulty of writing a secure sandbox.

When you run Java on your desktop, or on a server, you trust the Java code you are running, so you are not relying on the sandbox. In that context the main concern is whether untrusted data can interfere with the application. For example, if you're talking to someone on Skype, could they send a malicious message that Skype mishandles and allows them to take control of your computer. (I'm just using Skype as an example here).

There have been very few instances where bugs in the Java runtime would allow a desktop or server application to be hacked. Typically this happens because of bugs in the application code, not Java itself.


Mysql Information schema column_privileges empty I can try some SQL-injection against a ad-hoc damn web application in my virtual enviroment for educational purpose.
In one of these I obtain the table column_privileges (of Mysql Information schema) empty, I retrive the table but the fiels are empty. Is it possible that this table is empty or I have not the privileges to see it? Is there some test to obtain the confirm that I have not the privilege to see this table? In the case it is really empty, does this imply some important consideration?

It is no possible see information about database objects for which you don't have permissions. An empty information_schema table suggests a permissions issue for the user you are using to connect to the server.


Question about SSL certificate and third party server I have a system which consume web-services from a public server on Internet (but the data are not public) I have to provide credentials in Basic Auth to get the data, that is why we use SSL.

The server itself have a SSL certificate and it is signed by a Issuer Certificate from e.g "Company A" which is itself signed by a Root CA (let say Company B).

My question is about which certificate I have to put in my trust store (a Java JVM) and what is the best practices?

I know if I put the server certificate itself, when it expire I have to renew it but for example I see now they already changed it before the expiry date (like two month before).
If I trust the Issuer certificate (Company A) or the Root CA (Company B), I am afraid to trust too much servers that I do not need for now.

The best practice is to trust the root CA, for very practical reasons.

Root CAs are a special beast and are expected to have very long lifetimes (20 years or more) because they require replacement in the client software, which is usually a manual process.

Intermediate and server certificates are expected to change frequently - in some cases (load balancing for example) they can change minute-by-minute.  You should not expect to receive any notification from the server operator when the certificate changes.

If you put the root CA in your trust store, you're saying "I trust this CA - any and every certificate signed by this CA is ok with me".  That's usually ok, since the point of the CA is to provide a trustworthy signature for unknown servers.

The only time you would want to use a server certificate is when you don't trust the CA - but that itself causes further problems, and perhaps TLS is not the right approach in this case.


With WiFi now having protected management frames, is it still worth attempting an evil twin attack? I was trying to aireplay'ng my home WiFi but I understood that with the new generation of APs, there is a system of protected management frames. So I'm asking, is it still worth it to perform an evil twin attack? I think not, because without deauthenticating a station, the client will never go to search for a new connection.

So, what is your opinion? And is there any new way to perform an attack on WPA2?

Evil twin attacks are still possible. Deauth is only one of the things that can be used in evil twin attacks, are not the most crucial. Maybe the client's WiFi is turned off, then when it is turned on, it sees the evil twin. It may try to authenticate with, and associate with, the evil twin. Even though there has been no deauth attack done on the client.


Scanning my network with NMAP Each computer is assigned one ip address on my network, and my ISP supplies one IP for my network. If I try to scan the ip supplied by my ISP what I got is the OS running on the router, running on the firmware.

How do I scan my internal network from outside?

For example

Computers on my network:

192.168.0.200

192.168.0.201

192.168.0.202

192.168.0.203

IP supplied by my ISP 69.160.50.5

What TCP ports are open and which OS is running on 192.168.0.202? How can achieve this If all I have is 69.160.50.5? Thanks in advance.

First of all you need to understand how things actually work, so take a look here: NAT. This is how your router currently makes internet communication for all your hosts possible.

So, everything is behind a NAT, and that's exactly why you can't access any host using your public IP address. If you want a machine inside your private home network to be publicly available (I mean its services) you would have to give it access to it. In order to do that you would have either to forward some ports from your router to a specific machine inside your network or add the whole machine to the DMZ.

Example 1: I run a webserver at 192.168.1.30:80, so in order to make it accessible from the outside (using my public IP) I need to add a forwarding rule into my router configuration, so that port 80 would be "redirected" to 192.168.1.30:80. So if someone was to browse to http://my_public_ip:80 (you don't have to actually type ":80" here), his request would arrive to my router and it would be forwarded to my 192.168.1.30 machine, eventually showing whatever web page I was running on it. The same applies to every other service you want to make accessible to the public, let's say a FTP server. You can forward specific ports or ranges of them. Sample image:

Example 2: As you realise the above scenario is not always practical. Sometimes you just want to make an entire machine/internal IP the default receiver of all outside requests. This is where the DMZ comes in. If I want every outside request to bypass my router and always arrive to a specific host I would add its IP (eg 192.168.1.123) to my DMZ. Sample image:

Take a look at this question too, for more insights concerning the use of DMZ. Don't be afraid to use it for your purposes though.

As you realise both of the above configurations are done inside your router interface.


Security concerns with TCP holding onto out-of-order packets? Consider the following...

Alice and Bob are communicating over TCP.  Currently, the next expected TCP sequence number is 1000.  Charlie, pretending to be Alice, sends a spoofed TCP packet to Bob with a sequence number of 1003.  Bob's computer holds onto this packet thinking that it arrived out of order. Meanwhile, Alice continues sending packets to Bob, sequenced as 1000, 1001, and 1002. Now, Bob's computer processes the spoofed TCP packet thinking it is the next in sequence.

In this scenario, assuming my understanding is correct, it seems that the attacker doesn't need to exactly predict the next sequence number, but rather just needs to guess the a sequence number that is greater than or equal to the current sequence, but also close enough to the sequence number so that it doesn't expire... as surely it won't hold on to the out-of-order packet forever.

This raises the following questions...

1) Is my understanding of the scenario I described correct?

2) What determines how long an out-of-order packet should be kept, while it waits for the previously sent packets?

3) What would happen to the TCP session when Alice finally sends a packet with TCP sequence 1003, given that Charlie's spoofed packet was already processed?

This is limited by the TCP window size.

It's not enough to just guess any number greater than the sequence number; it must be between the sequence number and (sequence number + window size).

I don't know how much easier this makes brute forcing a sequence number in practice. "Overlapping fragments" has been the cause of some historic vulnerabilities, but I believe all modern TCP stacks have good defences.


Why do browsers default to http: and not https: for typed in URLs? When I type example.com without any scheme into the browser bar and press Enter it is interpreted as HTTP://example.com, not HTTPS://example.com.  Why?  And where are the plans to fix this?

(To be clear, I'm talking only about typed/pasted addresses coming from a "lazy" user, not about software-defined actions such as following scheme-relative URLs, window.location = "url" etc.  And obviously typing/pasting HTTP://example.com must still work.)

EDIT: As some answers point out sites already can mostly achieve this with redirects + HSTS.  The central technical gain would be narrowing the first-connection problem (also addressed by HSTS preload but that can't scale to all sites).  I can see how that's a weak justification for breaking things now; what I'm more interested in is whether it's an obvious endgame in 5 years? 10? 20?

I can see several problems on the way to defaulting to https interpretation:

User experience with sites that only work over http.  Defaulting to https would show an error but the user usually has no idea whether it should work, i.e. whether this site simply never worked over https or is this a downgrade attack.

If the error page for this situation will contain an easy "did you mean http:...?" link(*), users will get used to clicking that on any site that doesn't work and we haven't gained much(?).  And if it's not easy (e.g. user must edit https->http, users won't use such browser.

EDIT: I should have clarified that the error indication must be different from explicitly going to an HTTPS address which failed — this scenario is not so much "fail" as "the safe interpretation didn't work".  And for starters, even "soft failing" automatically to HTTP with a warning bar on top would be OK.

But I think we still gain 3 things: going to unsecure site is a conscious action, we educate users that unsecure HTTP is not normal, and we put pressure on sites to implement https.
Inconvenience of having to type http:// in some cases.  IMO completely outweighed by convenience of not having to type https:// in more cases.
"Compatibility" with the historical default.  I'm not sure if it's enshrined in some standard, but IMO it's clear we'll have to change it some day, so that's not a showstopper.
Politics/economics: the CA system has its issues and browsers might be reluctant to pressure site admins to pay them (if they don't otherwise see value in that).  Let's ignore money for a moment and pretend Let's Encrypt free CA has arrived.

I can see why making the change right now can be controversial; what baffles me is why it's not widely discussed as the obvious long-term goal, with some staged plan a-la the SHA-2 certs deprection though maybe slower.  What I see seems to assume http will remain default practically forever:

Chrome's move to hiding http:// in URL bar is a step back.  The first step towards https default should have been showing http in red; at some later time eventually move to hiding https:// (only showing green padlock)...
HSTS moves in the right direction but with cautious per-site opt-in.  It's both weaker and stronger — sites opt in to forcing https even for explicit http urls, with no user recourse for errors — but the RFC doesn't even mention the idea that https could be a global default, or that browser default scheme is to blame for bootsrap MITM problem.
I've seen DNSSEC mentioned as future vector for HSTS-like opt-in but again never saw proposals for opt-out...

Also, are there any browsers (or extensions) offering this as an option?

Browsers are applications for end-users.
While the majority of sites is available by http (even if they just redirect to https) a significant part is not available by https.
Thus your proposal would break web surfing for a very large part of the users. It would break in a way they don't understand. Automatically downgrading to http if https fails would not make sense because an attacker could then just simply cause havoc with connections to port 443 to enforce downgrades.

Once all but a few insignificant sites switched to https one could make the switch to a more secure default, but not yet. End-users would not understand what happened and probably just switch to an alternate browser or get some tips from somewhere on the internet to get back the old behavior.

Security decisions have to be done with and not against the users.