Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should setting id_ only set the local part of the ID? #222

Open
MarkDavidson opened this issue Oct 27, 2014 · 6 comments
Open

Should setting id_ only set the local part of the ID? #222

MarkDavidson opened this issue Oct 27, 2014 · 6 comments

Comments

@MarkDavidson
Copy link
Contributor

Right now, properly setting custom IDs is somewhat counter-intuitive (to me).

The python-stix documentation has information on setting ID namespaces [1], which at present boils down to set_id_namespace({"http://MY-NAMESPACE.com" : "myNS"}) which causes myNS to be registered as an alias for http://MY-NAMESPACE.com.

After setting the namespace, IDs currently need to be set with the namespace alias in mind. For example: sp = STIXPackage(id_='myNS:SomeID') is required if you want to use SomeID instead of an auto-generated ID. However, I think this might trip some people up. I think some people would expect the id_ kwarg to just set the local part, and that the API would automatically prepend the alias (e.g., myNS). For example, I could see people thinking that sp = STIXPackage(id_='local_part_only') would create a valid ID because the APIs would "know" to prepend the NS alias.

This issue is to discuss this point of view and, should there be a consensus, possibly modify the implementation of IDs. One outcome could be that if there is not a namespace alias set in the id_ property, use the ID namespace. If there is a namespace alias set in the id_ property, use the specified namespace alias.

Thoughts?

Note: #176 might be related

[1] http://stix.readthedocs.org/en/latest/examples/index.html#id-namespaces

@MarkDavidson
Copy link
Contributor Author

FYI (Where I'm coming from): crits/crits#285

@packet-rat
Copy link

@MarkDavidson - I originally thought it was the way I was setting namespaces in crits/core/crits_mongoengine.py:

    #
    # Set the STIX namsespace to replace "example"
    from stix.utils import set_id_namespace
    STIXNAMESPACE = {"http://intinc.specere.org" : "INTINC-Dev"}
    set_id_namespace(STIXNAMESPACE)
    # Set the CybOx namespace to replace example
    from cybox.utils import set_id_namespace, Namespace
    from cybox.core import Observable

    CYBOXNAMESPACE = Namespace("http://intinc.specere.org" , "INTINC-Dev")
    set_id_namespace(CYBOXNAMESPACE)

Note: Suggest setting the Namespace attributes et al be handled as config localizations vs. requiring modifications to core modules.

Also note that I've gone back to STIX packages created before any Namespace customizations (the original Example) and see the same artifacts:

<stix:STIX_Package 
    xmlns:cyboxCommon="http://cybox.mitre.org/common-2"
    xmlns:cybox="http://cybox.mitre.org/cybox-2"
    xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
    xmlns:ArtifactObj="http://cybox.mitre.org/objects#ArtifactObject-2"
    xmlns:FileObj="http://cybox.mitre.org/objects#FileObject-2"
    xmlns:URIObj="http://cybox.mitre.org/objects#URIObject-2"
    xmlns:example="http://example.com"
    xmlns:incident="http://stix.mitre.org/Incident-1"
    xmlns:indicator="http://stix.mitre.org/Indicator-2"
    xmlns:stixCommon="http://stix.mitre.org/common-1"
    xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
    xmlns:stix="http://stix.mitre.org/stix-1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://cybox.mitre.org/common-2 http://cybox.mitre.org/XMLSchema/common/2.1/cybox_common.xsd
    http://cybox.mitre.org/cybox-2 http://cybox.mitre.org/XMLSchema/core/2.1/cybox_core.xsd
    http://cybox.mitre.org/default_vocabularies-2 http://cybox.mitre.org/XMLSchema/default_vocabularies/2.1/cybox_default_vocabularies.xsd
    http://cybox.mitre.org/objects#ArtifactObject-2 http://cybox.mitre.org/XMLSchema/objects/Artifact/2.1/Artifact_Object.xsd
    http://cybox.mitre.org/objects#FileObject-2 http://cybox.mitre.org/XMLSchema/objects/File/2.1/File_Object.xsd
    http://cybox.mitre.org/objects#URIObject-2 http://cybox.mitre.org/XMLSchema/objects/URI/2.1/URI_Object.xsd
    http://stix.mitre.org/Incident-1 http://stix.mitre.org/XMLSchema/incident/1.1.1/incident.xsd
    http://stix.mitre.org/Indicator-2 http://stix.mitre.org/XMLSchema/indicator/2.1.1/indicator.xsd
    http://stix.mitre.org/common-1 http://stix.mitre.org/XMLSchema/common/1.1.1/stix_common.xsd
    http://stix.mitre.org/default_vocabularies-1 http://stix.mitre.org/XMLSchema/default_vocabularies/1.1.1/stix_default_vocabularies.xsd
    http://stix.mitre.org/stix-1 http://stix.mitre.org/XMLSchema/core/1.1.1/stix_core.xsd" id="71f3d913-52bb-480e-a95b-c4b466ed7e18" version="1.1.1" timestamp="2014-10-13T20:48:49.678029+00:00">
    <stix:STIX_Header>
        <stix:Title>Test</stix:Title>
        <stix:Package_Intent xsi:type="stixVocabs:PackageIntentVocab-1.0">Threat Report</stix:Package_Intent>
        <stix:Description>This is the Event Main Description Field</stix:Description>
        <stix:Information_Source>
            <stixCommon:Identity id="example:Identity-1ff30e47-89d1-4314-be5b-5613e04e464a">
                <stixCommon:Name>INTINC-Dev</stixCommon:Name>
            </stixCommon:Identity>
            <stixCommon:Time>
                <cyboxCommon:Produced_Time>2014-10-13T16:48:49.677859</cyboxCommon:Produced_Time>
            </stixCommon:Time>
            <stixCommon:Tools>
                <cyboxCommon:Tool>
                    <cyboxCommon:Name>CRITs</cyboxCommon:Name>
                    <cyboxCommon:Vendor>MITRE</cyboxCommon:Vendor>
                    <cyboxCommon:Version>4-master</cyboxCommon:Version>
                </cyboxCommon:Tool>
            </stixCommon:Tools>
        </stix:Information_Source>
    </stix:STIX_Header>
    <stix:Observables cybox_major_version="2" cybox_minor_version="1" cybox_update_version="0">
        <cybox:Observable id="example:Observable-164552bc-ad4f-4b3c-97dc-6c8dc0eac2c6">
            <cybox:Object id="example:File-04820cce-520b-40c5-8b33-877c99255702">
                <cybox:Properties xsi:type="FileObj:FileObjectType">
                    <FileObj:File_Name>20140610 DDoS attack UDP - NTP on 30 MAY 2014 Source_IPs.txt</FileObj:File_Name>
                    <FileObj:Size_In_Bytes>5342</FileObj:Size_In_Bytes>
                    <FileObj:File_Format>ASCII text, with CRLF line terminators</FileObj:File_Format>
                    <FileObj:Hashes>
                        <cyboxCommon:Hash>
                            <cyboxCommon:Type xsi:type="cyboxVocabs:HashNameVocab-1.0">MD5</cyboxCommon:Type>
                            <cyboxCommon:Simple_Hash_Value>6e6d0f5a3c1052c1ea19258e62e0209e</cyboxCommon:Simple_Hash_Value>
                        </cyboxCommon:Hash>
                        <cyboxCommon:Hash>
                            <cyboxCommon:Type xsi:type="cyboxVocabs:HashNameVocab-1.0">SHA1</cyboxCommon:Type>
                            <cyboxCommon:Simple_Hash_Value>efdf3e4fa344a31ffff6ba56fc29ebdbd839f0dc</cyboxCommon:Simple_Hash_Value>
                        </cyboxCommon:Hash>
                        <cyboxCommon:Hash>
                            <cyboxCommon:Type xsi:type="cyboxVocabs:HashNameVocab-1.0">SHA256</cyboxCommon:Type>
                            <cyboxCommon:Simple_Hash_Value>b4654e9cdf7c3b68cb048a50e92e5570f4f52667190002c18aa43a45bf9dbf0e</cyboxCommon:Simple_Hash_Value>
                        </cyboxCommon:Hash>
                        <cyboxCommon:Hash>
                            <cyboxCommon:Type xsi:type="cyboxVocabs:HashNameVocab-1.0">SSDEEP</cyboxCommon:Type>
                            <cyboxCommon:Simple_Hash_Value>96:1O/CkPTAweF/XvYEePw65CU5KnxiVVxxJdhs0ShrQTapjKob0mABD:1OhAwQ/eZzVVzJd+0qQTaQobbAB</cyboxCommon:Simple_Hash_Value>
                        </cyboxCommon:Hash>
                    </FileObj:Hashes>
                </cybox:Properties>
                <cybox:Related_Objects>
                    <cybox:Related_Object id="example:Artifact-bbbaf757-7aa1-481b-83fc-63340a12c913">
                        <cybox:Properties xsi:type="ArtifactObj:ArtifactObjectType" type="File">
                            <ArtifactObj:Packaging>
                                <ArtifactObj:Encoding algorithm="Base64"/>
                            </ArtifactObj:Packaging>
                            <ArtifactObj:Raw_Artifact><![CDATA[MTA5LjExMS4yMzUuOTgNCjU5LjE0NS4xMzIuNzANCjYxLjM2LjIxOS4zNg0KMTI1LjIxLjU1LjE0DQo0Ni4xOS45OS44DQoxODguMjQxLjIwMC4yDQo1OS4xNDUuMjMyLjYNCjE4MC4yMzUuMTYzLjQyDQoxODcuNjAuMjE1LjY2DQo4Mi4xMTku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0KODYuNTMuMTE5Ljk4DQoxNzcuMTA0LjI1My4xOA0KNzcuODguMjE5LjQyDQo4Ni41My4xMjguMTIyDQoxODYuMjA4LjEyNy4xMDYNCjEwNS4yMzUuMjI1LjIyMw0KMTc3LjIyMy4wLjM2DQoxMjMuNjMuMjE0LjkzDQo2Ny4yMjIuMTYxLjINCjg2LjEwMS4xNzkuNDYNCjgyLjE0OC4xNjAuMjIyDQoxNzYuMTE5LjIyNC41MA0KMjEzLjIxNy4xNTUuMjUwDQoyMTIuMzkuMTI1Ljg2DQoxOTYuNDEuOS4yNg0KOTMuODcuNzMuMTU0DQoyMTMuMTM1LjkzLjUyDQoxOTUuMTc4LjMzLjE3MA0KMTc3LjM4LjguMTA2DQoyMDAuMTEwLjkzLjQ4DQo2Ni43Ni4xMTUuMTU4DQoxNzcuNS4yNDcuMTcwDQoxODMuOTEuODUuMTMwDQo5MS4yMjYuNTAuNDMNCjE4Ny40NC4xMzguMzQNCjEwMy4yNDEuNC4yNDYNCjIxMi45MS4xODkuNg0KMjAxLjE2OC4yMDQuNDINCjYyLjEyLjE3Ny4xNTUNCjE4Mi4xOS42MS4xNDkNCjIwMi4xNTIuNDMuMTUwDQoyNy4xMjMuMjE1LjIyMg0KMTU5LjI1NS4xNjcuNDkNCjE3OC44OS4xMDcuMzA=]]></ArtifactObj:Raw_Artifact>
                        </cybox:Properties>
                        <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Child_Of</cybox:Relationship>
                    </cybox:Related_Object>
                </cybox:Related_Objects>
            </cybox:Object>
        </cybox:Observable>
    </stix:Observables>
    <stix:Indicators>
        <stix:Indicator id="example:indicator-c1c43f28-40c1-4ce2-a22c-a44a09f61f4a" timestamp="2014-10-13T20:48:49.674587+00:00" xsi:type='indicator:IndicatorType' negate="false" version="2.1.1">
            <indicator:Observable id="example:Observable-988add80-f1cc-42a7-b4c1-35bd7242ab37">
                <cybox:Object id="example:URI-fb10373d-134f-47f1-b088-c4b63e9a50a1">
                    <cybox:Properties xsi:type="URIObj:URIObjectType" type="URL">
                        <URIObj:Value>http://badguys.com/badstuff.php</URIObj:Value>
                    </cybox:Properties>
                </cybox:Object>
            </indicator:Observable>
            <indicator:Producer>
                <stixCommon:Identity id="example:Identity-093c3b8d-a95d-4e17-819a-2e5f38006cff">
                    <stixCommon:Name>INTINC-Dev</stixCommon:Name>
                </stixCommon:Identity>
            </indicator:Producer>
        </stix:Indicator>
        <stix:Indicator id="example:indicator-d52d546e-8f88-411b-91b4-5d4946bcb22c" timestamp="2014-10-13T20:48:49.674993+00:00" xsi:type='indicator:IndicatorType' negate="false" version="2.1.1">
            <indicator:Observable id="example:Observable-47900804-fd63-4e42-8684-bf075ec71206">
                <cybox:Object id="example:URI-671e0386-3cbb-40ef-a254-c2cf58367917">
                    <cybox:Properties xsi:type="URIObj:URIObjectType" type="URL">
                        <URIObj:Value>http://reallybadguys.com/badstuff.php</URIObj:Value>
                    </cybox:Properties>
                </cybox:Object>
            </indicator:Observable>
            <indicator:Producer>
                <stixCommon:Identity id="example:Identity-0aa49c35-e7eb-43a6-9742-c0237e7b3d9a">
                    <stixCommon:Name>INTINC-Dev</stixCommon:Name>
                </stixCommon:Identity>
            </indicator:Producer>
        </stix:Indicator>
    </stix:Indicators>
</stix:STIX_Package>

@MarkDavidson
Copy link
Contributor Author

Ah - I think I see what's happening.

In CRITs, the STIX_Package/id is being created with [1]:

stix_msg['stix_obj'] = STIXPackage(indicators=stix_msg['stix_indicators'],
                        observables=Observables(stix_msg['stix_observables']),
                        threat_actors=stix_msg['stix_actors'],
                        stix_header=header,
                        id_=uuid.uuid4())

What's funny is, it's only schema-invalid if the leading character of the UUID is a number. So a UUIDs of the form [a-f].... is schema valid while UUIDs of the forms [0-9]... are not. Therefore, the issue might not show up right away, and won't always show up.

I see three possible remediations, all probably belong in the CRITs code:

  1. Prefix all IDs with package (per the suggested practices [2])
  2. Have CRITs use the defined namespace prefix.
  3. Both

Edit: Opened an issue here: crits/crits#289

[1] https://github.com/crits/crits/blob/master/crits/core/crits_mongoengine.py#L764
[2] http://stixproject.github.io/documentation/suggested-practices/

@mgoffin
Copy link

mgoffin commented Oct 27, 2014

If I am reading the documentation properly, the reason that this isn't an issue is because STIX prefers that you add a construct-type in front of the GUID, thus guaranteeing there is a letter at the beginning of the ID?

@MarkDavidson
Copy link
Contributor Author

@mgoffin,

You are correct that prefixing the GUID with something (like package) guarantees that the ID will be a schema valid QName (why QNames are OK with letters but not numbers, I have no idea).

-Mark

@bworrell
Copy link
Contributor

@MarkDavidson, @mgoffin ,

A quick observation regarding the CRITs example that @MarkDavidson provided:

stix_msg['stix_obj'] = STIXPackage(indicators=stix_msg['stix_indicators'],
                        observables=Observables(stix_msg['stix_observables']),
                        threat_actors=stix_msg['stix_actors'],
                        stix_header=header,
                        id_=uuid.uuid4())

I think one way to approach this may be to just not set the id_ paramter in __init__. By not specifying an id_ parameter, python-stix will generate one.

Internally, python-stix uses uuid.uuid4() but prepends the ns alias and construct type as well, rendering a valid STIX id. The namespace portion of the id can be adjusted via the set_id_namespace method that @MarkDavidson mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants