Add QEMU Disk Image Extractor#1691
Conversation
|
Testbed: google/security-testbeds#187 |
|
Hello @0xXA Thanks for the contribution! I left a few comments that may need your attention. Could you also consider splitting the |
Thanks for the comments gentleman. I don't think it's a wise idea to split |
|
Hi @0xXA
I'm having troubles understanding the code flow logic right now. Please, split this into separate files. I noticed that some components implement complicated patterns such as encryption and raw binary data manipulation. To ensure correctness please also test those components separately. Note: Please, in future let me mark conversation as resolved in order for me to understand what is resolved or not |
|
if there are specific larger categories of helper functions those would be useful to move to separate files (ideally with separate tests for their major functions) |
|
As a separate question, are there any helper libraries available for any of the qcow2 parsing logic being implemented here? Since we already need to import a couple new helper libs like github.com/emmansun/gmsm/sm4 it should be fine to introduce a few more if that helps reduce the SCALIBR code size. |
|
Some encryption code related to grains and tables parsing can't be tested individually because we can't fully emulate or recreate format behavior at the spot. It'll complicate the plugin because all we want is to just read and understand the format for our job. I'll move rest of the code to separate files.
Good question. There are no known working qcow2 parsers in Golang. It took me 2 months to create this parser: Reverse Engineering the format by hand from disk, slicing files sector by sector, testing those sectors individually through manually encrypting / decrypting using masterkey materials, manually recreating the masterkey materials to match the behavior of But that's what makes it interesting. Just like a Patek Philippe, it's a masterpiece. |
I will separate IV related logic into iv.go, crypto related logic in crypto.go, and compression related logic in compression.go, format related stuff in format.go. Everything else will be in qcow2.go. Does this align with what you intend to do Erik !? |
Closes: google#1213 Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
@erikvarga Done! |
|
Hello @0xXA Thanks for the changes. I noticed that the
Alternatively, adding another |
Thanks for reviewing @alessandro-Doyensec really appreciate your effort man. I have added the mentioned test cases. |
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
Hello @0xXA, To clarify my previous #1691 (comment): I noticed that this pattern/bug is present in other filesystem/embeddedfs packages like I suggest to update |
Yes, this should work for me. wrt testing, as long as we trigger the code paths added to the businesslogic with either individual tests or qcow2 testdata files with the right format I think that should be good enough for the test coverage. |
I think it's best to remove the call to disk.Close() in that case. Also, I won't touch code in other extractors unless you consider that as extra work or you can do it yourself.
Sure thing. |
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
@erikvarga can you rerun the actions !? Just addressed a comment made by @alessandro-Doyensec |
IIUIC this is currently a problem in other extractors as well then? That they call Close() on disk which is nil if GetDiskPartitions returns an error? If that's the case we can do a separate cleanup pass (e.g. moving the close into GetDiskPartitions) after this PR is merged. |
👍 Basically every |
Looking around I see a couple qcow2 implementations such as https://github.com/zchee/go-qcow2 Do these generally not parse the disk file in a format compatible with the fs interface we're using? Just checking that we're doing our due diligence before adding a large amount of new code to SCALIBR. |
I highly doubt they’re going to work. Besides none of the above mentioned links support qcow2 v3 header. Moreover, some of them are experimental and don’t support the features encountered in everyday qcow2 file. For example,
The best way to verify this is by comparing the qcow2 header against what I’ve implemented. What I meant by that statement is that there are no known working parsers that fully adhere to the current qcow2 specification. Experimental or partially implemented features don’t count. The whole point of this plugin is to handle regular files as well as edge cases (including encryption). If it doesn’t even support basic features like compression (which almost all real-world qcow2 files use)then there’s no point in adding this plugin. It would only take up more space. |
|
@erikvarga I have addressed all the comments. |
|
Whats sup with this internal server error !? |
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
I have added the required comment, could you rerun the actions @erikvarga !? |
|
Hi @erikvarga As previously agreed, all Salesforce extractors were to be considered as 2 validations and 2 detections, and the n-tuples plugin + pair plugin rework was to be treated as additional work. However, the issued reward does not seem to align with the overall amount of work completed. Could you please discuss this with the panel and consider revising the reward accordingly? Since this PR is merged, can you please assign me something else to work on !? |
|
I brought up the payout amount for this submission with the rest of the panel and the consensus was that different secret types for a single platform should be grouped as one PRP and that reward amounts should be capped at the maximum amount for the category. For transparency, this was the only secret scanner contribution that received the maximum payout so far since the PRP has resumed this year - other contributions involving less work have received lower amounts. |
We haven't finished evaluating all the new PRP submissions yet so we'll likely need until tomorrow to decide on new issue assignments. |
Appreciate you looking into it brother :) From my understanding, Payout for, 1 detection + 1 validation (complex) = n-detection + n-validation Is that true ? Capping the payout at max for different secret types belonging to same product makes sense but Salesforce is not the only group of secret detectors that will benefit from n-tuples plugin. I thought you’ll increase the reward beyond max payout if it benefits several other secret detectors. Just like you did with VMDK and embedded FS extractors or is this thing only applies to secret detectors !?
Sure thing. |
More specifically, detection for the N most relevant secrets of a single platform is accepted as one submission, and the payout for detection+validation of the secrets is capped to the amounts described. See the updated "Secret Detectors" section of https://bughunters.google.com/about/rules/open-source/osv-scalibr-patch-rewards-program-rules#reward-amounts |
|
Hi @0xXA , Our internal crypto reviewer noticed that there are no unit tests for the usage of the XTS cipher mode and for Serpent. |
Done! |
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
@erikvarga Any update on this ? |
|
@0xXA I added your changes to our internal import and am now waiting for the crypto reviewer to take another look. |
Appreciate the update. |
Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
|
Any update on this, @erikvarga ? |
|
Still waiting for crypto review, I'll ping the reviewer on Monday if there's no progress. |
|
Sure. What does this mean in the context of Software Inventory Extractor payouts:
Can you give an example of a plugin which satisfies this ? |
|
For example, plugin should find new vulns that we wouldn't previously have found when enabled together with I don't recall us having paid out this reward amount so far since most new package types don't have existing vuln feeds integrated into OSV.dev. One candidate for this might be #1775 depending on the number of vulns associated with MCP that we wouldn't have otherwise found. |
|
Im not sure if I understood it correctly but let’s say I added X extractor, X can’t be detected through standard package manager configurations because it wasn’t stalled with any standard package manager(say dpkg, etc). Now if I add an extractor for X to osv-scalibr. What else do I need to add so I get the full Reward for this category? |
PiperOrigin-RevId: 873956307
|
Merged in 0afbfa3 |
Closes: #1213